Commit 2f8b0ab3 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/my/mysql-4.1


sql/item.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
parents 6a931667 af84ae00
...@@ -1971,7 +1971,7 @@ print_field_types(MYSQL_RES *result) ...@@ -1971,7 +1971,7 @@ print_field_types(MYSQL_RES *result)
MYSQL_FIELD *field; MYSQL_FIELD *field;
while ((field = mysql_fetch_field(result))) while ((field = mysql_fetch_field(result)))
{ {
tee_fprintf(PAGER,"Catalog: '%s'\nDatabase: '%s'\nTable: '%s'\nName: '%s'\nType: %d\nLength: %d\nMax length: %d\nIs_null: %d\nFlags: %d\nDecimals: %d\n\n", tee_fprintf(PAGER,"Catalog: '%s'\nDatabase: '%s'\nTable: '%s'\nName: '%s'\nType: %d\nLength: %ld\nMax length: %ld\nIs_null: %d\nFlags: %u\nDecimals: %u\n\n",
field->catalog, field->db, field->table, field->name, field->catalog, field->db, field->table, field->name,
(int) field->type, (int) field->type,
field->length, field->max_length, field->length, field->max_length,
...@@ -2017,7 +2017,8 @@ print_table_data(MYSQL_RES *result) ...@@ -2017,7 +2017,8 @@ print_table_data(MYSQL_RES *result)
(void) tee_fputs("|", PAGER); (void) tee_fputs("|", PAGER);
for (uint off=0; (field = mysql_fetch_field(result)) ; off++) for (uint off=0; (field = mysql_fetch_field(result)) ; off++)
{ {
tee_fprintf(PAGER, " %-*s|",min(field->max_length,MAX_COLUMN_LENGTH), tee_fprintf(PAGER, " %-*s|",(int) min(field->max_length,
MAX_COLUMN_LENGTH),
field->name); field->name);
num_flag[off]= IS_NUM(field->type); num_flag[off]= IS_NUM(field->type);
} }
......
...@@ -362,8 +362,7 @@ DYNAMIC_STRING ds_res; ...@@ -362,8 +362,7 @@ DYNAMIC_STRING ds_res;
static void die(const char *fmt, ...); static void die(const char *fmt, ...);
static void init_var_hash(); static void init_var_hash();
static VAR* var_from_env(const char *, const char *); static VAR* var_from_env(const char *, const char *);
static byte* get_var_key(const byte* rec, uint* len, static byte* get_var_key(const byte* rec, uint* len, my_bool t);
my_bool __attribute__((unused)) t);
static VAR* var_init(VAR* v, const char *name, int name_len, const char *val, static VAR* var_init(VAR* v, const char *name, int name_len, const char *val,
int val_len); int val_len);
...@@ -1807,6 +1806,10 @@ int read_line(char* buf, int size) ...@@ -1807,6 +1806,10 @@ int read_line(char* buf, int size)
continue; continue;
} }
/* Line counting is independent of state */
if (c == '\n')
(*lineno)++;
switch(state) { switch(state) {
case R_NORMAL: case R_NORMAL:
/* Only accept '{' in the beginning of a line */ /* Only accept '{' in the beginning of a line */
...@@ -1822,14 +1825,12 @@ int read_line(char* buf, int size) ...@@ -1822,14 +1825,12 @@ int read_line(char* buf, int size)
else if (c == '\n') else if (c == '\n')
{ {
state = R_LINE_START; state = R_LINE_START;
(*lineno)++;
} }
break; break;
case R_COMMENT: case R_COMMENT:
if (c == '\n') if (c == '\n')
{ {
*p= 0; *p= 0;
(*lineno)++;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
break; break;
...@@ -1841,7 +1842,7 @@ int read_line(char* buf, int size) ...@@ -1841,7 +1842,7 @@ int read_line(char* buf, int size)
else if (my_isspace(charset_info, c)) else if (my_isspace(charset_info, c))
{ {
if (c == '\n') if (c == '\n')
start_lineno= ++*lineno; /* Query hasn't started yet */ start_lineno= *lineno; /* Query hasn't started yet */
no_save= 1; no_save= 1;
} }
else if (c == '}') else if (c == '}')
......
...@@ -585,7 +585,7 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key, ...@@ -585,7 +585,7 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key,
char_length / seg->charset->mbmaxlen); char_length / seg->charset->mbmaxlen);
set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */
if (char_length < seg->length) if (char_length < seg->length)
seg->charset->cset->fill(seg->charset, key + char_length, seg->charset->cset->fill(seg->charset, (char*) key + char_length,
seg->length - char_length, ' '); seg->length - char_length, ' ');
} }
memcpy(key, rec + seg->start, (size_t) char_length); memcpy(key, rec + seg->start, (size_t) char_length);
...@@ -634,7 +634,7 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, ...@@ -634,7 +634,7 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old,
char_length / seg->charset->mbmaxlen); char_length / seg->charset->mbmaxlen);
set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */
if (char_length < seg->length) if (char_length < seg->length)
seg->charset->cset->fill(seg->charset, key + char_length, seg->charset->cset->fill(seg->charset, (char*) key + char_length,
seg->length - char_length, ' '); seg->length - char_length, ' ');
} }
memcpy(key, old, (size_t) char_length); memcpy(key, old, (size_t) char_length);
......
...@@ -92,7 +92,7 @@ dict_get_first_table_name_in_db( ...@@ -92,7 +92,7 @@ dict_get_first_table_name_in_db(
/* We found one */ /* We found one */
char* table_name = mem_strdupl(field, len); char* table_name = mem_strdupl((char*) field, len);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
...@@ -154,7 +154,7 @@ dict_print(void) ...@@ -154,7 +154,7 @@ dict_print(void)
/* We found one */ /* We found one */
char* table_name = mem_strdupl(field, len); char* table_name = mem_strdupl((char*) field, len);
btr_pcur_store_position(&pcur, &mtr); btr_pcur_store_position(&pcur, &mtr);
...@@ -246,7 +246,7 @@ dict_check_tablespaces_or_store_max_id( ...@@ -246,7 +246,7 @@ dict_check_tablespaces_or_store_max_id(
/* We found one */ /* We found one */
char* name = mem_strdupl(field, len); char* name = mem_strdupl((char*) field, len);
field = rec_get_nth_field(rec, 9, &len); field = rec_get_nth_field(rec, 9, &len);
ut_a(len == 4); ut_a(len == 4);
...@@ -347,7 +347,7 @@ dict_load_columns( ...@@ -347,7 +347,7 @@ dict_load_columns(
dict_table_get_first_index(sys_columns), 4))->name)); dict_table_get_first_index(sys_columns), 4))->name));
field = rec_get_nth_field(rec, 4, &len); field = rec_get_nth_field(rec, 4, &len);
name = mem_heap_strdupl(heap, field, len); name = mem_heap_strdupl(heap, (char*) field, len);
field = rec_get_nth_field(rec, 5, &len); field = rec_get_nth_field(rec, 5, &len);
mtype = mach_read_from_4(field); mtype = mach_read_from_4(field);
...@@ -494,7 +494,7 @@ dict_load_fields( ...@@ -494,7 +494,7 @@ dict_load_fields(
field = rec_get_nth_field(rec, 4, &len); field = rec_get_nth_field(rec, 4, &len);
dict_mem_index_add_field(index, dict_mem_index_add_field(index,
mem_heap_strdupl(heap, field, len), 0, prefix_len); mem_heap_strdupl(heap, (char*) field, len), 0, prefix_len);
btr_pcur_move_to_next_user_rec(&pcur, &mtr); btr_pcur_move_to_next_user_rec(&pcur, &mtr);
} }
...@@ -597,7 +597,7 @@ dict_load_indexes( ...@@ -597,7 +597,7 @@ dict_load_indexes(
dict_table_get_first_index(sys_indexes), 4))->name)); dict_table_get_first_index(sys_indexes), 4))->name));
field = rec_get_nth_field(rec, 4, &name_len); field = rec_get_nth_field(rec, 4, &name_len);
name_buf = mem_heap_strdupl(heap, field, name_len); name_buf = mem_heap_strdupl(heap, (char*) field, name_len);
field = rec_get_nth_field(rec, 5, &len); field = rec_get_nth_field(rec, 5, &len);
n_fields = mach_read_from_4(field); n_fields = mach_read_from_4(field);
...@@ -805,7 +805,7 @@ dict_load_table( ...@@ -805,7 +805,7 @@ dict_load_table(
table->mix_id = mach_read_from_8(field); table->mix_id = mach_read_from_8(field);
field = rec_get_nth_field(rec, 8, &len); field = rec_get_nth_field(rec, 8, &len);
table->cluster_name = mem_heap_strdupl(heap, field, len); table->cluster_name = mem_heap_strdupl(heap, (char*) field, len);
#endif #endif
} }
...@@ -938,7 +938,7 @@ dict_load_table_on_id( ...@@ -938,7 +938,7 @@ dict_load_table_on_id(
/* Now we get the table name from the record */ /* Now we get the table name from the record */
field = rec_get_nth_field(rec, 1, &len); field = rec_get_nth_field(rec, 1, &len);
/* Load the table definition to memory */ /* Load the table definition to memory */
table = dict_load_table(mem_heap_strdupl(heap, field, len)); table = dict_load_table(mem_heap_strdupl(heap, (char*) field, len));
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
...@@ -1030,11 +1030,11 @@ dict_load_foreign_cols( ...@@ -1030,11 +1030,11 @@ dict_load_foreign_cols(
field = rec_get_nth_field(rec, 4, &len); field = rec_get_nth_field(rec, 4, &len);
foreign->foreign_col_names[i] = foreign->foreign_col_names[i] =
mem_heap_strdupl(foreign->heap, field, len); mem_heap_strdupl(foreign->heap, (char*) field, len);
field = rec_get_nth_field(rec, 5, &len); field = rec_get_nth_field(rec, 5, &len);
foreign->referenced_col_names[i] = foreign->referenced_col_names[i] =
mem_heap_strdupl(foreign->heap, field, len); mem_heap_strdupl(foreign->heap, (char*) field, len);
btr_pcur_move_to_next_user_rec(&pcur, &mtr); btr_pcur_move_to_next_user_rec(&pcur, &mtr);
} }
...@@ -1138,11 +1138,11 @@ dict_load_foreign( ...@@ -1138,11 +1138,11 @@ dict_load_foreign(
field = rec_get_nth_field(rec, 3, &len); field = rec_get_nth_field(rec, 3, &len);
foreign->foreign_table_name = foreign->foreign_table_name =
mem_heap_strdupl(foreign->heap, field, len); mem_heap_strdupl(foreign->heap, (char*) field, len);
field = rec_get_nth_field(rec, 4, &len); field = rec_get_nth_field(rec, 4, &len);
foreign->referenced_table_name = foreign->referenced_table_name =
mem_heap_strdupl(foreign->heap, field, len); mem_heap_strdupl(foreign->heap, (char*) field, len);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
...@@ -1256,7 +1256,7 @@ dict_load_foreigns( ...@@ -1256,7 +1256,7 @@ dict_load_foreigns(
/* Now we get a foreign key constraint id */ /* Now we get a foreign key constraint id */
field = rec_get_nth_field(rec, 1, &len); field = rec_get_nth_field(rec, 1, &len);
id = mem_heap_strdupl(heap, field, len); id = mem_heap_strdupl(heap, (char*) field, len);
btr_pcur_store_position(&pcur, &mtr); btr_pcur_store_position(&pcur, &mtr);
......
...@@ -136,10 +136,8 @@ void ...@@ -136,10 +136,8 @@ void
mem_heap_free_func( mem_heap_free_func(
/*===============*/ /*===============*/
mem_heap_t* heap, /* in, own: heap to be freed */ mem_heap_t* heap, /* in, own: heap to be freed */
const char* file_name __attribute__((unused)), const char* file_name, /* in: file name where freed */
/* in: file name where freed */ ulint line); /* in: line where freed */
ulint line __attribute__((unused)));
/* in: line where freed */
/******************************************************************* /*******************************************************************
Allocates n bytes of memory from a memory heap. */ Allocates n bytes of memory from a memory heap. */
UNIV_INLINE UNIV_INLINE
......
...@@ -1807,7 +1807,7 @@ os_file_pread( ...@@ -1807,7 +1807,7 @@ os_file_pread(
os_file_n_pending_preads++; os_file_n_pending_preads++;
os_mutex_exit(os_file_count_mutex); os_mutex_exit(os_file_count_mutex);
n_bytes = pread(file, buf, n, offs); n_bytes = pread(file, buf, (ssize_t)n, offs);
os_mutex_enter(os_file_count_mutex); os_mutex_enter(os_file_count_mutex);
os_file_n_pending_preads--; os_file_n_pending_preads--;
...@@ -1832,7 +1832,7 @@ os_file_pread( ...@@ -1832,7 +1832,7 @@ os_file_pread(
return(ret); return(ret);
} }
ret = read(file, buf, n); ret = read(file, buf, (ssize_t)n);
os_mutex_exit(os_file_seek_mutexes[i]); os_mutex_exit(os_file_seek_mutexes[i]);
...@@ -1882,7 +1882,7 @@ os_file_pwrite( ...@@ -1882,7 +1882,7 @@ os_file_pwrite(
os_file_n_pending_pwrites++; os_file_n_pending_pwrites++;
os_mutex_exit(os_file_count_mutex); os_mutex_exit(os_file_count_mutex);
ret = pwrite(file, buf, n, offs); ret = pwrite(file, buf, (ssize_t)n, offs);
os_mutex_enter(os_file_count_mutex); os_mutex_enter(os_file_count_mutex);
os_file_n_pending_pwrites--; os_file_n_pending_pwrites--;
...@@ -1917,7 +1917,7 @@ os_file_pwrite( ...@@ -1917,7 +1917,7 @@ os_file_pwrite(
return(ret); return(ret);
} }
ret = write(file, buf, n); ret = write(file, buf, (ssize_t)n);
if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC
&& srv_unix_file_flush_method != SRV_UNIX_NOSYNC && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
......
...@@ -980,6 +980,23 @@ row_ins_foreign_check_on_constraint( ...@@ -980,6 +980,23 @@ row_ins_foreign_check_on_constraint(
err = row_update_cascade_for_mysql(thr, cascade, err = row_update_cascade_for_mysql(thr, cascade,
foreign->foreign_table); foreign->foreign_table);
if (foreign->foreign_table->n_foreign_key_checks_running == 0) {
fprintf(stderr,
"InnoDB: error: table %s has the counter 0 though there is\n"
"InnoDB: a FOREIGN KEY check running on it.\n",
foreign->foreign_table->name);
}
/* Release the data dictionary latch for a while, so that we do not
starve other threads from doing CREATE TABLE etc. if we have a huge
cascaded operation running. The counter n_foreign_key_checks_running
will prevent other users from dropping or ALTERing the table when we
release the latch. */
row_mysql_unfreeze_data_dictionary(thr_get_trx(thr));
row_mysql_freeze_data_dictionary(thr_get_trx(thr));
mtr_start(mtr); mtr_start(mtr);
/* Restore pcur position */ /* Restore pcur position */
......
...@@ -2479,8 +2479,8 @@ row_drop_table_for_mysql( ...@@ -2479,8 +2479,8 @@ row_drop_table_for_mysql(
fputs(" InnoDB: You are trying to drop table ", stderr); fputs(" InnoDB: You are trying to drop table ", stderr);
ut_print_name(stderr, trx, table->name); ut_print_name(stderr, trx, table->name);
fputs("\n" fputs("\n"
"InnoDB: though there are foreign key check running on it.\n" "InnoDB: though there is a foreign key check running on it.\n"
"InnoDB: Adding the table to the background drop queue.\n", "InnoDB: Adding the table to the background drop queue.\n",
stderr); stderr);
row_add_table_to_background_drop_list(table); row_add_table_to_background_drop_list(table);
......
...@@ -21,7 +21,7 @@ extern my_string mysql_unix_port; ...@@ -21,7 +21,7 @@ extern my_string mysql_unix_port;
CLIENT_TRANSACTIONS | \ CLIENT_TRANSACTIONS | \
CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION) CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
sig_handler pipe_sig_handler(int sig __attribute__((unused))); sig_handler pipe_sig_handler(int sig);
void read_user_name(char *name); void read_user_name(char *name);
my_bool handle_local_infile(MYSQL *mysql, const char *net_filename); my_bool handle_local_infile(MYSQL *mysql, const char *net_filename);
......
...@@ -99,6 +99,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) ...@@ -99,6 +99,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
info->update|= HA_STATE_AKTIV; /* for _mi_test_if_changed() */ info->update|= HA_STATE_AKTIV; /* for _mi_test_if_changed() */
/* The following should be safe, even if we compare doubles */
while (!r && gweight) while (!r && gweight)
{ {
...@@ -127,6 +128,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) ...@@ -127,6 +128,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
#else #else
#error #error
#endif #endif
/* The following should be safe, even if we compare doubles */
if (tmp_weight==0) if (tmp_weight==0)
DBUG_RETURN(doc_cnt); /* stopword, doc_cnt should be 0 */ DBUG_RETURN(doc_cnt); /* stopword, doc_cnt should be 0 */
......
...@@ -494,9 +494,11 @@ static uchar *rtree_pick_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, ...@@ -494,9 +494,11 @@ static uchar *rtree_pick_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
for (; k < last; k = rt_PAGE_NEXT_KEY(k, key_length, nod_flag)) for (; k < last; k = rt_PAGE_NEXT_KEY(k, key_length, nod_flag))
{ {
/* The following is safe as -1.0 is an exact number */
if ((increase = rtree_area_increase(keyinfo->seg, k, key, key_length, if ((increase = rtree_area_increase(keyinfo->seg, k, key, key_length,
&area)) == -1) &area)) == -1.0)
return NULL; return NULL;
/* The following should be safe, even if we compare doubles */
if (increase < best_incr) if (increase < best_incr)
{ {
best_key = k; best_key = k;
...@@ -505,6 +507,7 @@ static uchar *rtree_pick_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, ...@@ -505,6 +507,7 @@ static uchar *rtree_pick_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
} }
else else
{ {
/* The following should be safe, even if we compare doubles */
if ((increase == best_incr) && (area < best_area)) if ((increase == best_incr) && (area < best_area))
{ {
best_key = k; best_key = k;
...@@ -1021,6 +1024,7 @@ ha_rows rtree_estimate(MI_INFO *info, uint keynr, uchar *key, ...@@ -1021,6 +1024,7 @@ ha_rows rtree_estimate(MI_INFO *info, uint keynr, uchar *key,
{ {
double k_area = rtree_rect_volume(keyinfo->seg, k, key_length); double k_area = rtree_rect_volume(keyinfo->seg, k, key_length);
/* The following should be safe, even if we compare doubles */
if (k_area == 0) if (k_area == 0)
{ {
if (flag & (MBR_CONTAIN | MBR_INTERSECT)) if (flag & (MBR_CONTAIN | MBR_INTERSECT))
......
...@@ -129,6 +129,7 @@ int rtree_key_cmp(HA_KEYSEG *keyseg, uchar *b, uchar *a, uint key_length, ...@@ -129,6 +129,7 @@ int rtree_key_cmp(HA_KEYSEG *keyseg, uchar *b, uchar *a, uint key_length,
break; break;
#endif #endif
case HA_KEYTYPE_FLOAT: case HA_KEYTYPE_FLOAT:
/* The following should be safe, even if we compare doubles */
RT_CMP_GET(float, mi_float4get, 4, nextflag); RT_CMP_GET(float, mi_float4get, 4, nextflag);
break; break;
case HA_KEYTYPE_DOUBLE: case HA_KEYTYPE_DOUBLE:
......
...@@ -410,3 +410,17 @@ a a ...@@ -410,3 +410,17 @@ a a
1.1 1.2 1.1 1.2
2.1 2.2 2.1 2.2
deallocate prepare stmt; deallocate prepare stmt;
create table t1 (a int);
insert into t1 values (1),(2),(3);
create table t2 select * from t1;
PREPARE my_stmt FROM 'create table t2 select * from t1';
drop table t2;
execute my_stmt;
drop table t2;
execute my_stmt;
execute my_stmt;
ERROR 42S01: Table 't2' already exists
drop table t2;
execute my_stmt;
drop table t1,t2;
deallocate prepare my_stmt;
...@@ -415,3 +415,21 @@ execute stmt; ...@@ -415,3 +415,21 @@ execute stmt;
execute stmt; execute stmt;
execute stmt; execute stmt;
deallocate prepare stmt; deallocate prepare stmt;
#
# Test CREATE TABLE ... SELECT (Bug #6094)
#
create table t1 (a int);
insert into t1 values (1),(2),(3);
create table t2 select * from t1;
PREPARE my_stmt FROM 'create table t2 select * from t1';
drop table t2;
execute my_stmt;
drop table t2;
execute my_stmt;
--error 1050
execute my_stmt;
drop table t2;
execute my_stmt;
drop table t1,t2;
deallocate prepare my_stmt;
...@@ -174,6 +174,7 @@ static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax, ...@@ -174,6 +174,7 @@ static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax,
/* for compilers which can not handle inline */ /* for compilers which can not handle inline */
static
#if !defined(__SUNPRO_C) && !defined(__USLC__) && !defined(__sgi) #if !defined(__SUNPRO_C) && !defined(__USLC__) && !defined(__sgi)
inline inline
#endif #endif
......
...@@ -309,6 +309,11 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -309,6 +309,11 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_FLOAT: case HA_KEYTYPE_FLOAT:
mi_float4get(f_1,a); mi_float4get(f_1,a);
mi_float4get(f_2,b); mi_float4get(f_2,b);
/*
The following may give a compiler warning about floating point
comparison not being safe, but this is ok in this context as
we are bascily doing sorting
*/
if (piks && (flag = CMP_NUM(f_1,f_2))) if (piks && (flag = CMP_NUM(f_1,f_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
...@@ -317,6 +322,11 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -317,6 +322,11 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_DOUBLE: case HA_KEYTYPE_DOUBLE:
mi_float8get(d_1,a); mi_float8get(d_1,a);
mi_float8get(d_2,b); mi_float8get(d_2,b);
/*
The following may give a compiler warning about floating point
comparison not being safe, but this is ok in this context as
we are bascily doing sorting
*/
if (piks && (flag = CMP_NUM(d_1,d_2))) if (piks && (flag = CMP_NUM(d_1,d_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
......
...@@ -64,6 +64,11 @@ my_bool my_thread_global_init(void) ...@@ -64,6 +64,11 @@ my_bool my_thread_global_init(void)
} }
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
pthread_mutexattr_init(&my_fast_mutexattr); pthread_mutexattr_init(&my_fast_mutexattr);
/*
Note that the following statement may give a compiler warning under
some configurations, but there isn't anything we can do about this as
this is a bug in the header files for the thread implementation
*/
pthread_mutexattr_setkind_np(&my_fast_mutexattr,PTHREAD_MUTEX_ADAPTIVE_NP); pthread_mutexattr_setkind_np(&my_fast_mutexattr,PTHREAD_MUTEX_ADAPTIVE_NP);
#endif #endif
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
......
...@@ -78,7 +78,7 @@ char *argv[]; ...@@ -78,7 +78,7 @@ char *argv[];
if (err) { if (err) {
len = regerror(err, &re, erbuf, sizeof(erbuf)); len = regerror(err, &re, erbuf, sizeof(erbuf));
fprintf(stderr, "error %s, %d/%d `%s'\n", fprintf(stderr, "error %s, %d/%d `%s'\n",
eprint(err), len, sizeof(erbuf), erbuf); eprint(err), len, (int) sizeof(erbuf), erbuf);
exit(status); exit(status);
} }
regprint(&re, stdout); regprint(&re, stdout);
...@@ -96,7 +96,7 @@ char *argv[]; ...@@ -96,7 +96,7 @@ char *argv[];
if (err) { if (err) {
len = regerror(err, &re, erbuf, sizeof(erbuf)); len = regerror(err, &re, erbuf, sizeof(erbuf));
fprintf(stderr, "error %s, %d/%d `%s'\n", fprintf(stderr, "error %s, %d/%d `%s'\n",
eprint(err), len, sizeof(erbuf), erbuf); eprint(err), (int) len, (int) sizeof(erbuf), erbuf);
exit(status); exit(status);
} }
if (!(copts&REG_NOSUB)) { if (!(copts&REG_NOSUB)) {
...@@ -232,7 +232,7 @@ int opts; /* may not match f1 */ ...@@ -232,7 +232,7 @@ int opts; /* may not match f1 */
len = regerror(err, &re, erbuf, sizeof(erbuf)); len = regerror(err, &re, erbuf, sizeof(erbuf));
fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n", fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
line, type, eprint(err), len, line, type, eprint(err), len,
sizeof(erbuf), erbuf); (int) sizeof(erbuf), erbuf);
status = 1; status = 1;
} else if (err == 0 && opt('C', f1)) { } else if (err == 0 && opt('C', f1)) {
/* unexpected success */ /* unexpected success */
...@@ -263,7 +263,7 @@ int opts; /* may not match f1 */ ...@@ -263,7 +263,7 @@ int opts; /* may not match f1 */
len = regerror(err, &re, erbuf, sizeof(erbuf)); len = regerror(err, &re, erbuf, sizeof(erbuf));
fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n", fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
line, type, eprint(err), len, line, type, eprint(err), len,
sizeof(erbuf), erbuf); (int) sizeof(erbuf), erbuf);
status = 1; status = 1;
} else if (err != 0) { } else if (err != 0) {
/* nothing more to check */ /* nothing more to check */
......
...@@ -97,7 +97,8 @@ class Item { ...@@ -97,7 +97,8 @@ class Item {
static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); } static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
static void *operator new(size_t size, MEM_ROOT *mem_root) static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); } { return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr,size_t size) {} /*lint -e715 */ static void operator delete(void *ptr,size_t size) {}
static void operator delete(void *ptr,size_t size, MEM_ROOT *mem_root) {}
enum Type {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM, enum Type {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM,
INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM, INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM,
......
...@@ -348,6 +348,7 @@ class Item_dec_func :public Item_real_func ...@@ -348,6 +348,7 @@ class Item_dec_func :public Item_real_func
#ifndef HAVE_FINITE #ifndef HAVE_FINITE
return value; return value;
#else #else
/* The following should be safe, even if we compare doubles */
if (finite(value) && value != POSTFIX_ERROR) if (finite(value) && value != POSTFIX_ERROR)
return value; return value;
null_value=1; null_value=1;
...@@ -1032,6 +1033,7 @@ class Item_func_match :public Item_real_func ...@@ -1032,6 +1033,7 @@ class Item_func_match :public Item_real_func
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref); bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref);
bool eq(const Item *, bool binary_cmp) const; bool eq(const Item *, bool binary_cmp) const;
/* The following should be safe, even if we compare doubles */
longlong val_int() { DBUG_ASSERT(fixed == 1); return val()!=0.0; } longlong val_int() { DBUG_ASSERT(fixed == 1); return val()!=0.0; }
double val(); double val();
void print(String *str); void print(String *str);
......
...@@ -97,12 +97,14 @@ struct MBR ...@@ -97,12 +97,14 @@ struct MBR
int equals(const MBR *mbr) int equals(const MBR *mbr)
{ {
/* The following should be safe, even if we compare doubles */
return ((mbr->xmin == xmin) && (mbr->ymin == ymin) && return ((mbr->xmin == xmin) && (mbr->ymin == ymin) &&
(mbr->xmax == xmax) && (mbr->ymax == ymax)); (mbr->xmax == xmax) && (mbr->ymax == ymax));
} }
int disjoint(const MBR *mbr) int disjoint(const MBR *mbr)
{ {
/* The following should be safe, even if we compare doubles */
return ((mbr->xmin > xmax) || (mbr->ymin > ymax) || return ((mbr->xmin > xmax) || (mbr->ymin > ymax) ||
(mbr->xmax < xmin) || (mbr->ymax < ymin)); (mbr->xmax < xmin) || (mbr->ymax < ymin));
} }
...@@ -114,6 +116,7 @@ struct MBR ...@@ -114,6 +116,7 @@ struct MBR
int touches(const MBR *mbr) int touches(const MBR *mbr)
{ {
/* The following should be safe, even if we compare doubles */
return ((((mbr->xmin == xmax) || (mbr->xmax == xmin)) && return ((((mbr->xmin == xmax) || (mbr->xmax == xmin)) &&
((mbr->ymin >= ymin) && (mbr->ymin <= ymax) || ((mbr->ymin >= ymin) && (mbr->ymin <= ymax) ||
(mbr->ymax >= ymin) && (mbr->ymax <= ymax))) || (mbr->ymax >= ymin) && (mbr->ymax <= ymax))) ||
...@@ -124,18 +127,21 @@ struct MBR ...@@ -124,18 +127,21 @@ struct MBR
int within(const MBR *mbr) int within(const MBR *mbr)
{ {
/* The following should be safe, even if we compare doubles */
return ((mbr->xmin <= xmin) && (mbr->ymin <= ymin) && return ((mbr->xmin <= xmin) && (mbr->ymin <= ymin) &&
(mbr->xmax >= xmax) && (mbr->ymax >= ymax)); (mbr->xmax >= xmax) && (mbr->ymax >= ymax));
} }
int contains(const MBR *mbr) int contains(const MBR *mbr)
{ {
/* The following should be safe, even if we compare doubles */
return ((mbr->xmin >= xmin) && (mbr->ymin >= ymin) && return ((mbr->xmin >= xmin) && (mbr->ymin >= ymin) &&
(mbr->xmax <= xmax) && (mbr->ymax <= ymax)); (mbr->xmax <= xmax) && (mbr->ymax <= ymax));
} }
bool inner_point(double x, double y) const bool inner_point(double x, double y) const
{ {
/* The following should be safe, even if we compare doubles */
return (xmin<x) && (xmax>x) && (ymin<y) && (ymax>x); return (xmin<x) && (xmax>x) && (ymin<y) && (ymax>x);
} }
...@@ -164,6 +170,9 @@ class Geometry ...@@ -164,6 +170,9 @@ class Geometry
return buffer; return buffer;
} }
static void operator delete(void *ptr, void *buffer)
{}
enum wkbType enum wkbType
{ {
wkb_point= 1, wkb_point= 1,
......
...@@ -241,6 +241,7 @@ class st_select_lex_node { ...@@ -241,6 +241,7 @@ class st_select_lex_node {
static void *operator new(size_t size, MEM_ROOT *mem_root) static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); } { return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr,size_t size) {} static void operator delete(void *ptr,size_t size) {}
static void operator delete(void *ptr,size_t size, MEM_ROOT *mem_root) {}
st_select_lex_node(): linkage(UNSPECIFIED_TYPE) {} st_select_lex_node(): linkage(UNSPECIFIED_TYPE) {}
virtual ~st_select_lex_node() {} virtual ~st_select_lex_node() {}
inline st_select_lex_node* get_master() { return master; } inline st_select_lex_node* get_master() { return master; }
......
...@@ -41,6 +41,8 @@ class Sql_alloc ...@@ -41,6 +41,8 @@ class Sql_alloc
static void *operator new(size_t size, MEM_ROOT *mem_root) static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); } { return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); }
static void operator delete(void *ptr, size_t size, MEM_ROOT *mem_root)
{ TRASH(ptr, size); }
static void operator delete[](void *ptr, size_t size) { TRASH(ptr, size); } static void operator delete[](void *ptr, size_t size) { TRASH(ptr, size); }
#ifdef HAVE_purify #ifdef HAVE_purify
bool dummy; bool dummy;
......
...@@ -1573,7 +1573,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1573,7 +1573,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (check_access(thd,CREATE_ACL,db,0,1,0)) if (check_access(thd,CREATE_ACL,db,0,1,0))
break; break;
mysql_log.write(thd,command,packet); mysql_log.write(thd,command,packet);
mysql_create_db(thd,(lower_case_table_names == 2 ? alias : db),0,0); if (mysql_create_db(thd, (lower_case_table_names == 2 ? alias : db),
0, 0) < 0)
send_error(thd, thd->killed ? ER_SERVER_SHUTDOWN : 0);
break; break;
} }
case COM_DROP_DB: // QQ: To be removed case COM_DROP_DB: // QQ: To be removed
...@@ -1594,7 +1596,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1594,7 +1596,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break; break;
} }
mysql_log.write(thd,command,db); mysql_log.write(thd,command,db);
mysql_rm_db(thd, (lower_case_table_names == 2 ? alias : db), 0, 0); if (mysql_rm_db(thd, (lower_case_table_names == 2 ? alias : db),
0, 0) < 0)
send_error(thd, thd->killed ? ER_SERVER_SHUTDOWN : 0);
break; break;
} }
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
...@@ -1862,8 +1866,8 @@ mysql_execute_command(THD *thd) ...@@ -1862,8 +1866,8 @@ mysql_execute_command(THD *thd)
{ {
int res= 0; int res= 0;
LEX *lex= thd->lex; LEX *lex= thd->lex;
TABLE_LIST *tables= (TABLE_LIST*) lex->select_lex.table_list.first;
SELECT_LEX *select_lex= &lex->select_lex; SELECT_LEX *select_lex= &lex->select_lex;
TABLE_LIST *tables= (TABLE_LIST*) select_lex->table_list.first;
SELECT_LEX_UNIT *unit= &lex->unit; SELECT_LEX_UNIT *unit= &lex->unit;
DBUG_ENTER("mysql_execute_command"); DBUG_ENTER("mysql_execute_command");
...@@ -2333,30 +2337,6 @@ mysql_execute_command(THD *thd) ...@@ -2333,30 +2337,6 @@ mysql_execute_command(THD *thd)
{ {
select_result *result; select_result *result;
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) &&
find_real_table_in_list(tables, create_table->db,
create_table->real_name))
{
net_printf(thd,ER_UPDATE_TABLE_USED, create_table->real_name);
goto create_error;
}
if (lex->create_info.used_fields & HA_CREATE_USED_UNION)
{
TABLE_LIST *tab;
for (tab= tables; tab; tab= tab->next)
{
if (find_real_table_in_list((TABLE_LIST*) lex->create_info.
merge_list.first,
tables->db, tab->real_name))
{
net_printf(thd, ER_UPDATE_TABLE_USED, tab->real_name);
goto create_error;
}
}
}
if (tables && check_table_access(thd, SELECT_ACL, tables,0))
goto create_error; // Error message is given
select_lex->options|= SELECT_NO_UNLOCK; select_lex->options|= SELECT_NO_UNLOCK;
unit->offset_limit_cnt= select_lex->offset_limit; unit->offset_limit_cnt= select_lex->offset_limit;
unit->select_limit_cnt= select_lex->select_limit+ unit->select_limit_cnt= select_lex->select_limit+
...@@ -5285,7 +5265,7 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) ...@@ -5285,7 +5265,7 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count)
INSERT ... SELECT query pre-check INSERT ... SELECT query pre-check
SYNOPSIS SYNOPSIS
multi_delete_precheck() insert_delete_precheck()
thd Thread handler thd Thread handler
tables Global table list tables Global table list
...@@ -5407,26 +5387,69 @@ int insert_precheck(THD *thd, TABLE_LIST *tables) ...@@ -5407,26 +5387,69 @@ int insert_precheck(THD *thd, TABLE_LIST *tables)
RETURN VALUE RETURN VALUE
0 OK 0 OK
1 Error (message is sent to user) 1 Error (message is sent to user)
-1 Error (message is not sent to user)
*/ */
int create_table_precheck(THD *thd, TABLE_LIST *tables, int create_table_precheck(THD *thd, TABLE_LIST *tables,
TABLE_LIST *create_table) TABLE_LIST *create_table)
{ {
LEX *lex= thd->lex; LEX *lex= thd->lex;
SELECT_LEX *select_lex= &lex->select_lex;
ulong want_priv;
int error= 1; // Error message is given
DBUG_ENTER("create_table_precheck"); DBUG_ENTER("create_table_precheck");
ulong want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ?
CREATE_TMP_ACL : CREATE_ACL); want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ?
CREATE_TMP_ACL : CREATE_ACL);
lex->create_info.alias= create_table->alias; lex->create_info.alias= create_table->alias;
if (check_access(thd, want_priv, create_table->db, if (check_access(thd, want_priv, create_table->db,
&create_table->grant.privilege, 0, 0) || &create_table->grant.privilege, 0, 0) ||
check_merge_table_access(thd, create_table->db, check_merge_table_access(thd, create_table->db,
(TABLE_LIST *) (TABLE_LIST *)
lex->create_info.merge_list.first)) lex->create_info.merge_list.first))
DBUG_RETURN(1); goto err;
DBUG_RETURN((grant_option && want_priv != CREATE_TMP_ACL && if (grant_option && want_priv != CREATE_TMP_ACL &&
check_grant(thd, want_priv, create_table, 0, UINT_MAX, 0)) ? check_grant(thd, want_priv, create_table, 0, UINT_MAX, 0))
1 : 0); goto err;
if (select_lex->item_list.elements)
{
/* Check permissions for used tables in CREATE TABLE ... SELECT */
/*
For temporary tables or PREPARED STATEMETNS we don't have to check
if the created table exists
*/
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) &&
! thd->current_arena->is_stmt_prepare() &&
find_real_table_in_list(tables, create_table->db,
create_table->real_name))
{
net_printf(thd,ER_UPDATE_TABLE_USED, create_table->real_name);
goto err;
}
if (lex->create_info.used_fields & HA_CREATE_USED_UNION)
{
TABLE_LIST *tab;
for (tab= tables; tab; tab= tab->next)
{
if (find_real_table_in_list((TABLE_LIST*) lex->create_info.
merge_list.first,
tables->db, tab->real_name))
{
net_printf(thd, ER_UPDATE_TABLE_USED, tab->real_name);
goto err;
}
}
}
if (tables && check_table_access(thd, SELECT_ACL, tables,0))
goto err;
}
error= 0;
err:
DBUG_RETURN(error);
} }
......
...@@ -1391,7 +1391,6 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) ...@@ -1391,7 +1391,6 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol)
lex->unit.create_total_list(thd, lex, &tables)) lex->unit.create_total_list(thd, lex, &tables))
DBUG_RETURN(1); DBUG_RETURN(1);
switch (sql_command) { switch (sql_command) {
case SQLCOM_REPLACE: case SQLCOM_REPLACE:
case SQLCOM_INSERT: case SQLCOM_INSERT:
......
...@@ -71,7 +71,9 @@ class String ...@@ -71,7 +71,9 @@ class String
} }
static void *operator new(size_t size, MEM_ROOT *mem_root) static void *operator new(size_t size, MEM_ROOT *mem_root)
{ return (void*) alloc_root(mem_root, (uint) size); } { return (void*) alloc_root(mem_root, (uint) size); }
static void operator delete(void *ptr_arg,size_t size) /*lint -e715 */ static void operator delete(void *ptr_arg,size_t size)
{}
static void operator delete(void *ptr_arg,size_t size, MEM_ROOT *mem_root)
{} {}
~String() { free(); } ~String() { free(); }
......
...@@ -502,7 +502,8 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, ...@@ -502,7 +502,8 @@ my_bool my_like_range_mb(CHARSET_INFO *cs,
representation of the max_sort_char character, representation of the max_sort_char character,
and copy it into max_str in a loop. and copy it into max_str in a loop.
*/ */
buflen= cs->cset->wc_mb(cs, cs->max_sort_char, buf, buf + sizeof(buf)); buflen= cs->cset->wc_mb(cs, cs->max_sort_char, (uchar*) buf,
(uchar*) buf + sizeof(buf));
DBUG_ASSERT(buflen > 0); DBUG_ASSERT(buflen > 0);
do do
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment