diff options
65 files changed, 233 insertions, 241 deletions
diff --git a/extra/comp_err.c b/extra/comp_err.c index a554fc2437e..85833999d5c 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -332,13 +332,13 @@ static int create_sys_files(struct languages *lang_head, head[30]= csnum; my_fseek(to, 0l, MY_SEEK_SET, MYF(0)); - if (my_fwrite(to, head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP))) + if (my_fwrite(to, (byte*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP))) goto err; for (i= 0; i < row_count; i++) { int2store(head, file_pos[i]); - if (my_fwrite(to, head, 2, MYF(MY_WME | MY_FNABP))) + if (my_fwrite(to, (byte*) head, 2, MYF(MY_WME | MY_FNABP))) goto err; } my_fclose(to, MYF(0)); diff --git a/extra/perror.c b/extra/perror.c index 6e632b20d96..d68f5230e4a 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -250,7 +250,8 @@ int main(int argc,char *argv[]) 'Unknown Error' (without regard to case). */ if (msg && - my_strnncoll(&my_charset_latin1, msg, 13, "Unknown Error", 13) && + my_strnncoll(&my_charset_latin1, (const uchar*) msg, 13, + (const uchar*) "Unknown Error", 13) && (!unknown_error || strcmp(msg, unknown_error))) { found=1; diff --git a/include/mysys_err.h b/include/mysys_err.h index 1e489395c76..341e6950792 100644 --- a/include/mysys_err.h +++ b/include/mysys_err.h @@ -26,10 +26,14 @@ extern "C" { extern const char * NEAR globerrs[]; /* my_error_messages is here */ /* Error message numbers in global map */ -/* Do not add error numbers before EE_ERROR_FIRST. */ -/* If necessary to add lower numbers, change EE_ERROR_FIRST accordingly. */ -#define EE_ERROR_FIRST 0 /*Copy first error nr.*/ -#define EE_FILENOTFOUND 0 +/* + Do not add error numbers before EE_ERROR_FIRST. + If necessary to add lower numbers, change EE_ERROR_FIRST accordingly. + + We start with error 1 to not confuse peoples with 'error 0' +*/ + +#define EE_ERROR_FIRST 1 /*Copy first error nr.*/ #define EE_CANTCREATEFILE 1 #define EE_READ 2 #define EE_WRITE 3 @@ -57,7 +61,8 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */ #define EE_REALPATH 26 #define EE_SYNC 27 #define EE_UNKNOWN_COLLATION 28 -#define EE_ERROR_LAST 28 /*Copy last error nr.*/ +#define EE_FILENOTFOUND 29 +#define EE_ERROR_LAST 29 /*Copy last error nr.*/ /* Add error numbers before EE_ERROR_LAST and change it accordingly. */ /* exit codes for all MySQL programs */ diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 6ec4809790e..035c84621ab 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2472,7 +2472,7 @@ dict_scan_id( my_isspace(). Only after that, convert id names to UTF-8. */ b = (byte*)(*id); - id_len = strlen(b); + id_len = strlen((char*) b); if (id_len >= 3 && b[id_len - 1] == 0xA0 && b[id_len - 2] == 0xC2) { diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c index 7fd1ca08c04..1f4ebe810b4 100644 --- a/innobase/dict/dict0load.c +++ b/innobase/dict/dict0load.c @@ -184,7 +184,7 @@ loop: if (table == NULL) { fputs("InnoDB: Failed to load table ", stderr); - ut_print_namel(stderr, NULL, field, len); + ut_print_namel(stderr, NULL, (char*) field, len); putc('\n', stderr); } else { /* The table definition was corrupt if there diff --git a/innobase/pars/pars0sym.c b/innobase/pars/pars0sym.c index 194e6677183..8ade5579e47 100644 --- a/innobase/pars/pars0sym.c +++ b/innobase/pars/pars0sym.c @@ -220,7 +220,7 @@ sym_tab_add_id( node->resolved = FALSE; node->indirection = NULL; - node->name = mem_heap_strdupl(sym_tab->heap, name, len + 1); + node->name = mem_heap_strdupl(sym_tab->heap, (char*) name, len + 1); node->name_len = len; UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node); diff --git a/innobase/row/row0row.c b/innobase/row/row0row.c index 43d0cd41b0a..438e54757cd 100644 --- a/innobase/row/row0row.c +++ b/innobase/row/row0row.c @@ -430,7 +430,7 @@ row_build_row_ref( dfield_set_len(dfield, dtype_get_at_most_n_mbchars( dfield_get_type(dfield), - clust_col_prefix_len, len, field)); + clust_col_prefix_len, len, (char*) field)); } } } @@ -525,7 +525,7 @@ row_build_row_ref_in_tuple( dfield_set_len(dfield, dtype_get_at_most_n_mbchars( dfield_get_type(dfield), - clust_col_prefix_len, len, field)); + clust_col_prefix_len, len, (char*) field)); } } } diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 22cece487a0..e0995c589d1 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -112,7 +112,7 @@ row_sel_sec_rec_is_for_clust_rec( clust_len = dtype_get_at_most_n_mbchars( cur_type, ifield->prefix_len, - clust_len, clust_field); + clust_len, (char*) clust_field); } if (0 != cmp_data_data(dict_col_get_type(col), diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 353f8cd6430..79fe36615b9 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -28,10 +28,6 @@ extern "C" extern unsigned long max_allowed_packet, net_buffer_length; } -static int fake_argc= 1; -static char *fake_argv[]= {(char *)"", 0}; -static const char *fake_groups[] = { "server", "embedded", 0 }; - #if defined (__WIN__) #include "../sql/mysqld.cpp" #else diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 6ac04d562e0..ab5ddd3a378 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -186,7 +186,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, FIX_LENGTH(cs, pos, length, char_length); memcpy((byte*) key, pos, char_length); if (length > char_length) - cs->cset->fill(cs, key+char_length, length-char_length, ' '); + cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' '); key+= length; } _mi_dpointer(info,key,filepos); @@ -296,7 +296,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, FIX_LENGTH(cs, pos, length, char_length); memcpy((byte*) key, pos, char_length); if (length > char_length) - cs->cset->fill(cs,key+char_length, length-char_length, ' '); + cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' '); key+= length; k_length-=length; } diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result index e53c3c3eb55..c7b4b1c4155 100644 --- a/mysql-test/r/backup.result +++ b/mysql-test/r/backup.result @@ -5,6 +5,8 @@ backup table t4 to '../bogus'; Table Op Msg_type Msg_text test.t4 backup error Failed copying .frm file (errno: X) test.t4 backup status Operation failed +Warnings: +Error 1 Can't create/write to file 'MYSQL_TEST_DIR/var/bogus/t4.frm' (Errcode: X) backup table t4 to '../tmp'; Table Op Msg_type Msg_text test.t4 backup status OK @@ -12,6 +14,8 @@ backup table t4 to '../tmp'; Table Op Msg_type Msg_text test.t4 backup error Failed copying .frm file (errno: X) test.t4 backup status Operation failed +Warnings: +Error 1 Can't create/write to file 'MYSQL_TEST_DIR/var/tmp/t4.frm' (Errcode: X) drop table t4; restore table t4 from '../tmp'; Table Op Msg_type Msg_text @@ -28,6 +32,8 @@ drop table t1; restore table t1 from '../bogus'; Table Op Msg_type Msg_text t1 restore error Failed copying .frm file +Warnings: +Error 29 File 'MYSQL_TEST_DIR/var/bogus/t1.frm' not found (Errcode: X) restore table t1 from '../tmp'; Table Op Msg_type Msg_text test.t1 restore status OK diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 91f74be9453..c63c869219a 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1453,18 +1453,18 @@ test.t1 2948697075 test.t2 NULL test.t3 NULL test.t4 NULL -checksum table t1, t2, t3, t4; +Warnings: +Error 1146 Table 'test.t4' doesn't exist +checksum table t1, t2, t3; Table Checksum test.t1 2948697075 test.t2 968604391 test.t3 968604391 -test.t4 NULL -checksum table t1, t2, t3, t4 extended; +checksum table t1, t2, t3 extended; Table Checksum test.t1 3092701434 test.t2 968604391 test.t3 968604391 -test.t4 NULL drop table t1,t2,t3; create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb; insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt'); diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result index 79b5a6e84b2..7c286ced58a 100644 --- a/mysql-test/r/key_cache.result +++ b/mysql-test/r/key_cache.result @@ -193,6 +193,8 @@ cache index t1 key (unknown_key) in keycache1; Table Op Msg_type Msg_text test.t1 assign_to_keycache error Key column 'unknown_key' doesn't exist in table test.t1 assign_to_keycache status Operation failed +Warnings: +Error 1072 Key column 'unknown_key' doesn't exist in table select @@keycache2.key_buffer_size; @@keycache2.key_buffer_size 4194304 diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 256bc1e3745..b0cb6462252 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -516,16 +516,22 @@ Table Checksum test.t1 2948697075 test.t2 NULL test.t3 NULL +Warnings: +Error 1146 Table 'test.t3' doesn't exist checksum table t1, t2, t3; Table Checksum test.t1 2948697075 test.t2 3092701434 test.t3 NULL +Warnings: +Error 1146 Table 'test.t3' doesn't exist checksum table t1, t2, t3 extended; Table Checksum test.t1 3092701434 test.t2 3092701434 test.t3 NULL +Warnings: +Error 1146 Table 'test.t3' doesn't exist drop table t1,t2; create table t1 (a int, key (a)); show keys from t1; diff --git a/mysql-test/r/preload.result b/mysql-test/r/preload.result index 7237a0da7e0..b5e6dcfcdbb 100644 --- a/mysql-test/r/preload.result +++ b/mysql-test/r/preload.result @@ -145,6 +145,8 @@ load index into cache t3, t2 key (primary,b) ; Table Op Msg_type Msg_text test.t3 preload_keys error Table 'test.t3' doesn't exist test.t2 preload_keys status OK +Warnings: +Error 1146 Table 'test.t3' doesn't exist show status like "key_read%"; Variable_name Value Key_read_requests 355 @@ -160,6 +162,9 @@ Table Op Msg_type Msg_text test.t3 preload_keys error Table 'test.t3' doesn't exist test.t2 preload_keys error Key column 'c' doesn't exist in table test.t2 preload_keys status Operation failed +Warnings: +Error 1146 Table 'test.t3' doesn't exist +Error 1072 Key column 'c' doesn't exist in table show status like "key_read%"; Variable_name Value Key_read_requests 0 diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result index 0347d3a52f5..d8fa4dbbb72 100644 --- a/mysql-test/r/repair.result +++ b/mysql-test/r/repair.result @@ -27,11 +27,15 @@ drop table t1; repair table t1 use_frm; Table Op Msg_type Msg_text test.t1 repair error Table 'test.t1' doesn't exist +Warnings: +Error 1146 Table 'test.t1' doesn't exist create table t1 engine=myisam SELECT 1,"table 1"; flush tables; repair table t1; Table Op Msg_type Msg_text test.t1 repair error Incorrect file format 't1' +Warnings: +Error 130 Incorrect file format 't1' repair table t1 use_frm; Table Op Msg_type Msg_text test.t1 repair warning Number of rows changed from 0 to 1 diff --git a/mysql-test/r/rpl_failed_optimize.result b/mysql-test/r/rpl_failed_optimize.result index 1576ec60500..c7199e56ec8 100644 --- a/mysql-test/r/rpl_failed_optimize.result +++ b/mysql-test/r/rpl_failed_optimize.result @@ -10,6 +10,10 @@ INSERT INTO t1 VALUES (1); OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status Operation failed +Warnings: +Error 1205 Lock wait timeout exceeded; try restarting transaction OPTIMIZE TABLE non_existing; Table Op Msg_type Msg_text test.non_existing optimize error Table 'test.non_existing' doesn't exist +Warnings: +Error 1146 Table 'test.non_existing' doesn't exist diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 49006a6fecf..738c011012d 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1598,6 +1598,8 @@ insert into t1 values (2); set sort_buffer_size = (select s1 from t1); ERROR 21000: Subquery returns more than 1 row do (select * from t1); +Warnings: +Error 1242 Subquery returns more than 1 row drop table t1; create table t1 (s1 char); insert into t1 values ('e'); diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test index ed24161bef5..8b3a46724ab 100644 --- a/mysql-test/t/backup.test +++ b/mysql-test/t/backup.test @@ -10,10 +10,10 @@ set SQL_LOG_BIN=0; drop table if exists t1, t2, t3; --enable_warnings create table t4(n int); ---replace_result "errno: 1" "errno: X" "errno: 2" "errno: X" "errno: 22" "errno: X" "errno: 23" "errno: X" +--replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQL_TEST_DIR MYSQL_TEST_DIR backup table t4 to '../bogus'; backup table t4 to '../tmp'; ---replace_result "errno: 7" "errno: X" "errno: 17" "errno: X" +--replace_result ": 7" ": X" ": 17" ": X" $MYSQL_TEST_DIR MYSQL_TEST_DIR backup table t4 to '../tmp'; drop table t4; restore table t4 from '../tmp'; @@ -23,6 +23,7 @@ create table t1(n int); insert into t1 values (23),(45),(67); backup table t1 to '../tmp'; drop table t1; +--replace_result ": 1" ": X" ": 2" ": X" ": 22" ": X" ": 23" ": X" $MYSQL_TEST_DIR MYSQL_TEST_DIR restore table t1 from '../bogus'; restore table t1 from '../tmp'; select n from t1; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 82f91081d03..797ad5cb5f9 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1058,8 +1058,8 @@ insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); insert t2 select * from t1; insert t3 select * from t1; checksum table t1, t2, t3, t4 quick; -checksum table t1, t2, t3, t4; -checksum table t1, t2, t3, t4 extended; +checksum table t1, t2, t3; +checksum table t1, t2, t3 extended; #show table status; drop table t1,t2,t3; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index f919bfced77..df3b8743b10 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -552,7 +552,7 @@ system rm ./var/master-data/test/t1.MYI ; drop table t1; create table t1 (a int) engine=myisam; system rm ./var/master-data/test/t1.MYD ; ---error 1105,6 +--error 1105,6,29 drop table t1; --error 1051 drop table t1; diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 7622a93e2a3..2355e92e58b 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -24,7 +24,7 @@ drop table if exists t1, t2, t3, t4; # START SLAVE will fail because it can't read the file (mode 000) # (system error 13) --replace_result $MYSQL_TEST_DIR TESTDIR ---error 1105,1105 +--error 1105,1105,29 start slave; system chmod 600 var/slave-data/master.info; # It will fail again because the file is empty so the slave cannot get valuable diff --git a/mysys/errors.c b/mysys/errors.c index d321e7f6125..75a2c7048a0 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -21,7 +21,6 @@ const char * NEAR globerrs[GLOBERRS]= { - "File '%s' not found (Errcode: %d)", "Can't create/write to file '%s' (Errcode: %d)", "Error reading file '%s' (Errcode: %d)", "Error writing file '%s' (Errcode: %d)", @@ -50,6 +49,8 @@ const char * NEAR globerrs[GLOBERRS]= "Error on realpath() on '%s' (Error %d)", "Can't sync file '%s' to disk (Errcode: %d)", "Collation '%s' is not a compiled collation and is not specified in the '%s' file", + "File '%s' not found (Errcode: %d)", + "" }; void init_glob_errs(void) @@ -61,7 +62,6 @@ void init_glob_errs(void) void init_glob_errs() { - EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)"; EE(EE_CANTCREATEFILE) = "Can't create/write to file '%s' (Errcode: %d)"; EE(EE_READ) = "Error reading file '%s' (Errcode: %d)"; EE(EE_WRITE) = "Error writing file '%s' (Errcode: %d)"; @@ -89,5 +89,6 @@ void init_glob_errs() EE(EE_REALPATH)= "Error on realpath() on '%s' (Error %d)"; EE(EE_SYNC)= "Can't sync file '%s' to disk (Errcode: %d)"; EE(EE_UNKNOWN_COLLATION)= "Collation '%s' is not a compiled collation and is not specified in the %s file"; + EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)"; } #endif diff --git a/regex/engine.c b/regex/engine.c index 6734560b9bf..c4c4efe7e2f 100644 --- a/regex/engine.c +++ b/regex/engine.c @@ -256,7 +256,7 @@ sopno stopst; register char *ssp; /* start of string matched by subsubRE */ register char *sep; /* end of string matched by subsubRE */ register char *oldssp; /* previous ssp */ - register char *dp; + register char *dp; /* used in debug mode to check asserts */ AT("diss", start, stop, startst, stopst); sp = start; diff --git a/sql/derror.cc b/sql/derror.cc index 4690e76d0e3..bee818a14c1 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -78,7 +78,6 @@ static bool read_texts(const char *file_name,const char ***point, char name[FN_REFLEN]; const char *buff; uchar head[32],*pos; - CHARSET_INFO *cset; // For future DBUG_ENTER("read_texts"); *point=0; // If something goes wrong @@ -104,7 +103,7 @@ Please install the latest version of this file.",name); } /* TODO: Convert the character set to server system character set */ - if (!(cset= get_charset(head[30],MYF(MY_WME)))) + if (!get_charset(head[30],MYF(MY_WME))) { sql_print_error("Character set #%d is not supported for messagefile '%s'", (int)head[30],name); diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index e0c9173f8da..ad17bd91d69 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -575,7 +575,7 @@ error: int ha_archive::write_row(byte * buf) { z_off_t written; - uint *bptr, *end; + uint *ptr, *end; DBUG_ENTER("ha_archive::write_row"); if (share->crashed) @@ -596,17 +596,17 @@ int ha_archive::write_row(byte * buf) We should probably mark the table as damagaged if the record is written but the blob fails. */ - for (bptr= table->s->blob_field, end=bptr + table->s->blob_fields ; - bptr != end ; - bptr++) + for (ptr= table->s->blob_field, end= ptr + table->s->blob_fields ; + ptr != end ; + ptr++) { - char *ptr; - uint32 size= ((Field_blob*) table->field[*bptr])->get_length(); + char *data_ptr; + uint32 size= ((Field_blob*) table->field[*ptr])->get_length(); if (size) { - ((Field_blob*) table->field[*bptr])->get_ptr(&ptr); - written= gzwrite(share->archive_write, ptr, (unsigned)size); + ((Field_blob*) table->field[*ptr])->get_ptr(&data_ptr); + written= gzwrite(share->archive_write, data_ptr, (unsigned)size); if (written != size) goto error; } @@ -630,7 +630,6 @@ error: int ha_archive::rnd_init(bool scan) { DBUG_ENTER("ha_archive::rnd_init"); - int read; // gzread() returns int, and we use this to check the header if (share->crashed) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); diff --git a/sql/field.cc b/sql/field.cc index 194f4522851..1538edc59a3 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -797,7 +797,7 @@ bool Field::needs_quotes(void) { DBUG_ENTER("Field::type_quote"); - switch(type()) { + switch (type()) { //FIX this when kernel is fixed case MYSQL_TYPE_VARCHAR : case FIELD_TYPE_STRING : @@ -827,10 +827,9 @@ bool Field::needs_quotes(void) case FIELD_TYPE_SET : case FIELD_TYPE_ENUM : DBUG_RETURN(0); - - default: DBUG_RETURN(0); + default: + DBUG_RETURN(0); } - DBUG_RETURN(0); } @@ -5034,7 +5033,7 @@ int Field_str::store(double nr) double anr= fabs(nr); int neg= (nr < 0.0) ? 1 : 0; if (field_length > 4 && field_length < 32 && - (anr < 1.0 ? anr > 1/(log_10[max(0,field_length-neg-2)]) /* -2 for "0." */ + (anr < 1.0 ? anr > 1/(log_10[max(0,(int) field_length-neg-2)]) /* -2 for "0." */ : anr < log_10[field_length-neg]-1)) use_scientific_notation= FALSE; @@ -5453,7 +5452,6 @@ int Field_varstring::cmp(const char *a_ptr, const char *b_ptr) int Field_varstring::key_cmp(const byte *key_ptr, uint max_key_length) { - char *blob1; uint length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); uint char_length= max_key_length / field_charset->mbmaxlen; @@ -5752,8 +5750,6 @@ void Field_varstring::set_key_image(char *buff,uint length) int Field_varstring::cmp_binary(const char *a_ptr, const char *b_ptr, uint32 max_length) { - char *a,*b; - uint diff; uint32 a_length,b_length; if (length_bytes == 1) @@ -7202,11 +7198,12 @@ uint32 calc_pack_length(enum_field_types type,uint32 length) case FIELD_TYPE_GEOMETRY: return 4+portable_sizeof_char_ptr; case FIELD_TYPE_SET: case FIELD_TYPE_ENUM: - case FIELD_TYPE_NEWDECIMAL: abort(); return 0; // This shouldn't happen + case FIELD_TYPE_NEWDECIMAL: + abort(); return 0; // This shouldn't happen case FIELD_TYPE_BIT: return length / 8; - default: return 0; + default: + return 0; } - return 0; // Keep compiler happy } diff --git a/sql/filesort.cc b/sql/filesort.cc index de14287003b..57ac113cfd5 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -772,7 +772,7 @@ static void make_sortkey(register SORTPARAM *param, */ SORT_ADDON_FIELD *addonf= param->addon_field; uchar *nulls= to; - DBUG_ASSERT(addonf); + DBUG_ASSERT(addonf != 0); bzero((char *) nulls, addonf->offset); to+= addonf->offset; for ( ; (field= addonf->field) ; addonf++) diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index d30435310dc..b5884b17093 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -494,7 +494,6 @@ int ha_heap::create(const char *name, TABLE *table_arg, for (; key_part != key_part_end; key_part++, seg++) { - uint flag= key_part->key_type; Field *field= key_part->field; if (pos->algorithm == HA_KEY_ALG_BTREE) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index eddc7616e66..f68ad99ac44 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2594,8 +2594,6 @@ ha_innobase::write_row( int error; longlong auto_inc; longlong dummy; - ibool incremented_auto_inc_for_stat = FALSE; - ibool incremented_auto_inc_counter = FALSE; ibool auto_inc_used= FALSE; DBUG_ENTER("ha_innobase::write_row"); @@ -5098,17 +5096,16 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) while (tmp_buff[i] != '/') i++; tmp_buff+= i + 1; - f_key_info.forein_id= make_lex_string(thd, f_key_info.forein_id, + f_key_info.forein_id= make_lex_string(thd, 0, tmp_buff, strlen(tmp_buff), 1); tmp_buff= foreign->referenced_table_name; i= 0; while (tmp_buff[i] != '/') i++; - f_key_info.referenced_db= make_lex_string(thd, f_key_info.referenced_db, + f_key_info.referenced_db= make_lex_string(thd, 0, tmp_buff, i, 1); tmp_buff+= i + 1; - f_key_info.referenced_table= make_lex_string(thd, - f_key_info.referenced_table, + f_key_info.referenced_table= make_lex_string(thd, 0, tmp_buff, strlen(tmp_buff), 1); for (i= 0;;) @@ -5717,15 +5714,12 @@ innodb_mutex_show_status( Protocol *protocol= thd->protocol; List<Item> field_list; mutex_t* mutex; - const char* file_name; - ulint line; ulint rw_lock_count= 0; ulint rw_lock_count_spin_loop= 0; ulint rw_lock_count_spin_rounds= 0; ulint rw_lock_count_os_wait= 0; ulint rw_lock_count_os_yield= 0; ulonglong rw_lock_wait_time= 0; - DBUG_ENTER("innodb_mutex_show_status"); field_list.push_back(new Item_empty_string("Mutex", FN_REFLEN)); diff --git a/sql/handler.cc b/sql/handler.cc index b76fbe5ccd5..cd3656c6f0d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -735,7 +735,7 @@ int ha_commit_or_rollback_by_xid(LEX_STRING *ident, bool commit) */ int ha_recover(HASH *commit_list) { - int error= 0, len, got; + int len, got; handlerton **ht= handlertons, **end_ht=ht+total_ha; XID *list=0; DBUG_ENTER("ha_recover"); @@ -907,7 +907,7 @@ int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv) for (; ht < end_ht; ht++) { int err; - DBUG_ASSERT((*ht)->savepoint_set); + DBUG_ASSERT((*ht)->savepoint_set != 0); if ((err= (*(*ht)->savepoint_rollback)(thd, (byte *)(sv+1)+(*ht)->savepoint_offset))) { // cannot happen my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); @@ -2219,7 +2219,7 @@ TYPELIB *ha_known_exts(void) (found_exts.elements+1), MYF(MY_WME | MY_FAE)); - DBUG_ASSERT(ext); + DBUG_ASSERT(ext != 0); known_extensions.count= found_exts.elements; known_extensions.type_names= ext; diff --git a/sql/item.cc b/sql/item.cc index 3b920bd218d..a1b0e576109 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -131,7 +131,6 @@ my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value) { String *res; char *end_ptr; - int error; if (!(res= val_str(&str_value))) return 0; // NULL or EOM @@ -1102,6 +1101,7 @@ bool Item_field::val_bool_result() case ROW_RESULT: default: DBUG_ASSERT(0); + return 0; // Shut up compiler } } @@ -2179,7 +2179,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list) else return NULL; - DBUG_ASSERT(field_name); + DBUG_ASSERT(field_name != 0); for (ORDER *cur_group= group_list ; cur_group ; cur_group= cur_group->next) { @@ -2188,7 +2188,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list) cur_field= (Item_field*) *cur_group->item; cur_match_degree= 0; - DBUG_ASSERT(cur_field->field_name); + DBUG_ASSERT(cur_field->field_name != 0); if (!my_strcasecmp(system_charset_info, cur_field->field_name, field_name)) @@ -2317,7 +2317,7 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select) { if (select_ref != not_found_item && !ambiguous_fields) { - DBUG_ASSERT(*select_ref); + DBUG_ASSERT(*select_ref != 0); if (!select->ref_pointer_array[counter]) { my_error(ER_ILLEGAL_REFERENCE, MYF(0), @@ -2514,7 +2514,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) } } - DBUG_ASSERT(ref); + DBUG_ASSERT(ref != 0); if (!from_field) return TRUE; if (ref == not_found_item && from_field == not_found_field) @@ -2960,7 +2960,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table) void Item_field::make_field(Send_field *tmp_field) { field->make_field(tmp_field); - DBUG_ASSERT(tmp_field->table_name); + DBUG_ASSERT(tmp_field->table_name != 0); if (name) tmp_field->col_name=name; // Use user supplied name } @@ -3457,7 +3457,7 @@ Item_ref::Item_ref(Item **item, const char *table_name_par, /* This constructor used to create some internals references over fixed items */ - DBUG_ASSERT(ref); + DBUG_ASSERT(ref != 0); if (*ref) set_properties(); } @@ -3528,9 +3528,6 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) { SELECT_LEX_UNIT *prev_unit= current_sel->master_unit(); SELECT_LEX *outer_sel= prev_unit->outer_select(); - ORDER *group_list= (ORDER*) current_sel->group_list.first; - bool ambiguous_fields= FALSE; - Item **group_by_ref= NULL; if (!(ref= resolve_ref_in_select_and_group(thd, this, current_sel))) return TRUE; /* Some error occurred (e.g. ambiguous names). */ @@ -3644,7 +3641,7 @@ bool Item_ref::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) break; /* Do not consider derived tables. */ } - DBUG_ASSERT(ref); + DBUG_ASSERT(ref != 0); if (!from_field) return TRUE; if (ref == not_found_item && from_field == not_found_field) @@ -4595,7 +4592,7 @@ void Item_cache_row::bring_value() Field *get_holder_example_field(THD *thd, Item *item, TABLE *table) { - DBUG_ASSERT(table); + DBUG_ASSERT(table != 0); Item_func *tmp_item= 0; if (item->type() == Item::FIELD_ITEM) diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index fe849bd213a..46b2770a12a 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1514,7 +1514,7 @@ int subselect_indexsubquery_engine::exec() uint subselect_single_select_engine::cols() { - DBUG_ASSERT(select_lex->join); // should be called after fix_fields() + DBUG_ASSERT(select_lex->join != 0); // should be called after fix_fields() return select_lex->join->fields_list.elements; } diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 9a4798b9dc9..3df985b6c99 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -532,7 +532,7 @@ bool Item_sum_sum_distinct::setup(THD *thd) void Item_sum_sum_distinct::clear() { DBUG_ENTER("Item_sum_sum_distinct::clear"); - DBUG_ASSERT(tree); /* we always have a tree */ + DBUG_ASSERT(tree != 0); /* we always have a tree */ null_value= 1; tree->reset(); DBUG_VOID_RETURN; @@ -554,7 +554,7 @@ bool Item_sum_sum_distinct::add() my_decimal value, *val= args[0]->val_decimal(&value); if (!args[0]->null_value) { - DBUG_ASSERT(tree); + DBUG_ASSERT(tree != 0); null_value= 0; my_decimal2binary(E_DEC_FATAL_ERROR, val, (char *) dec_bin_buff, args[0]->max_length, args[0]->decimals); @@ -567,7 +567,7 @@ bool Item_sum_sum_distinct::add() double val= args[0]->val_real(); if (!args[0]->null_value) { - DBUG_ASSERT(tree); + DBUG_ASSERT(tree != 0); null_value= 0; DBUG_PRINT("info", ("real: %lg, tree 0x%lx", val, (ulong)tree)); if (val) @@ -1179,7 +1179,6 @@ double Item_sum_hybrid::val_real() DBUG_ASSERT(0); return 0; } - return 0; // Keep compiler happy } longlong Item_sum_hybrid::val_int() diff --git a/sql/item_sum.h b/sql/item_sum.h index eca2ae188db..3faf4914eac 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -701,7 +701,6 @@ public: int err_not_used; char *end; String *res; - longlong value; CHARSET_INFO *cs; if (!(res= val_str(&str_value))) diff --git a/sql/log.cc b/sql/log.cc index b37d053dfd7..56d16c9c7cf 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -608,7 +608,7 @@ bool MYSQL_LOG::open(const char *log_name, write_file_name_to_index_file= 1; } - DBUG_ASSERT(my_b_inited(&index_file)); + DBUG_ASSERT(my_b_inited(&index_file) != 0); reinit_io_cache(&index_file, WRITE_CACHE, my_b_filelength(&index_file), 0, 0); if (need_start_event && !no_auto_events) @@ -2461,7 +2461,7 @@ void sql_print_information(const char *format, ...) */ #define TC_LOG_HEADER_SIZE (sizeof(tc_log_magic)+1) -static const char tc_log_magic[]={254, 0x23, 0x05, 0x74}; +static const char tc_log_magic[]={(char) 254, 0x23, 0x05, 0x74}; uint opt_tc_log_size=TC_LOG_MIN_SIZE; ulong tc_log_max_pages_used=0, tc_log_page_size=0, @@ -2928,7 +2928,6 @@ int TC_LOG_BINLOG::open(const char *opt_name) { const char *errmsg; - char last_event_type=UNKNOWN_EVENT; IO_CACHE log; File file; Log_event *ev=0; diff --git a/sql/log_event.cc b/sql/log_event.cc index fa193df40a2..7f92159208b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -673,7 +673,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, #endif { DBUG_ENTER("Log_event::read_log_event(IO_CACHE *, Format_description_log_event *"); - DBUG_ASSERT(description_event); + DBUG_ASSERT(description_event != 0); char head[LOG_EVENT_MINIMAL_HEADER_LEN]; /* First we only want to read at most LOG_EVENT_MINIMAL_HEADER_LEN, just to @@ -741,7 +741,7 @@ err: UNLOCK_MUTEX; if (!res) { - DBUG_ASSERT(error); + DBUG_ASSERT(error != 0); sql_print_error("Error in Log_event::read_log_event(): " "'%s', data_len: %d, event_type: %d", error,data_len,head[EVENT_TYPE_OFFSET]); @@ -772,7 +772,7 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len, { Log_event* ev; DBUG_ENTER("Log_event::read_log_event(char*,...)"); - DBUG_ASSERT(description_event); + DBUG_ASSERT(description_event != 0); DBUG_PRINT("info", ("binlog_version: %d", description_event->binlog_version)); if (event_len < EVENT_LEN_OFFSET || (uint) event_len != uint4korr(buf+EVENT_LEN_OFFSET)) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 2d4a1c3a0ad..58450014081 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -260,8 +260,7 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; /* The rest of the file is included in the server only */ #ifndef MYSQL_CLIENT -/* If set to 0, then the thread will ignore all warnings with level notes. - Set by executing SET SQL_NOTES=1 */ +/* If not set then the thread will ignore all warnings with level notes. */ #define OPTION_SQL_NOTES (1L << 31) /* Bits for different SQL modes modes (including ANSI mode) */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c230f976adc..687b1a4d36b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -838,9 +838,9 @@ static void __cdecl kill_server(int sig_ptr) #define RETURN_FROM_KILL_SERVER DBUG_VOID_RETURN #endif { - int sig=(int) (long) sig_ptr; // This is passed a int DBUG_ENTER("kill_server"); #ifndef EMBEDDED_LIBRARY + int sig=(int) (long) sig_ptr; // This is passed a int // if there is a signal during the kill in progress, ignore the other if (kill_in_progress) // Safety RETURN_FROM_KILL_SERVER; @@ -1166,7 +1166,7 @@ err: static void set_user(const char *user, struct passwd *user_info) { #if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) - DBUG_ASSERT(user_info); + DBUG_ASSERT(user_info != 0); #ifdef HAVE_INITGROUPS /* We can get a SIGSEGV when calling initgroups() on some systems when NSS @@ -1195,7 +1195,7 @@ static void set_user(const char *user, struct passwd *user_info) static void set_effective_user(struct passwd *user_info) { #if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__) - DBUG_ASSERT(user_info); + DBUG_ASSERT(user_info != 0); if (setregid((gid_t)-1, user_info->pw_gid) == -1) { sql_perror("setregid"); @@ -2228,6 +2228,8 @@ extern "C" int my_message_sql(uint error, const char *str, myf MyFlags) thd->query_error= 1; // needed to catch query errors during replication + if (!thd->no_warnings_for_error) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str); /* thd->lex->current_select == 0 if lex structure is not inited (not query command (COM_QUERY)) @@ -2239,8 +2241,6 @@ extern "C" int my_message_sql(uint error, const char *str, myf MyFlags) (thd->lex->current_select ? thd->lex->current_select->no_error : 0), (int) thd->is_fatal_error)); - - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str); } else { @@ -2334,8 +2334,11 @@ const char *load_default_groups[]= { "mysql_cluster", #endif "mysqld","server", MYSQL_BASE_VERSION, 0, 0}; + +#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) static const int load_default_groups_sz= sizeof(load_default_groups)/sizeof(load_default_groups[0]); +#endif /* Initialize one of the global date/time format variables @@ -3391,7 +3394,6 @@ int main(int argc, char **argv) static void bootstrap(FILE *file) { - int error= 0; DBUG_ENTER("bootstrap"); THD *thd= new THD; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ecf255b091d..12e5c60312b 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2011,7 +2011,6 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, TABLE_READ_PLAN **roru_read_plans; TABLE_READ_PLAN **cur_roru_plan; double roru_index_costs; - double blocks_in_index_read; ha_rows roru_total_records; double roru_intersect_part= 1.0; DBUG_ENTER("get_best_disjunct_quick"); @@ -2077,7 +2076,6 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge, roru_read_plans= (TABLE_READ_PLAN**)range_scans; goto skip_to_ror_scan; } - blocks_in_index_read= imerge_cost; if (cpk_scan) { /* @@ -5654,7 +5652,7 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() cur_quick_it.rewind(); cur_quick= cur_quick_it++; - DBUG_ASSERT(cur_quick); + DBUG_ASSERT(cur_quick != 0); /* We reuse the same instance of handler so we need to call both init and @@ -6099,7 +6097,7 @@ int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length, byte *cur_prefix) if (range) { /* Read the next record in the same range with prefix after cur_prefix. */ - DBUG_ASSERT(cur_prefix); + DBUG_ASSERT(cur_prefix != 0); result= file->index_read(record, cur_prefix, prefix_length, HA_READ_AFTER_KEY); if (result || (file->compare_key(file->end_range) <= 0)) diff --git a/sql/protocol.cc b/sql/protocol.cc index e14262fdbe0..81444500421 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -59,8 +59,8 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) uint length; char buff[MYSQL_ERRMSG_SIZE+2], *pos; #endif - const char *orig_err= err; NET *net= &thd->net; + bool generate_warning= 1; DBUG_ENTER("net_send_error"); DBUG_PRINT("enter",("sql_errno: %d err: %s", sql_errno, err ? err : net->last_error[0] ? @@ -85,14 +85,22 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) else { if ((err=net->last_error)[0]) + { sql_errno=net->last_errno; + generate_warning= 0; // This warning has already been given + } else { sql_errno=ER_UNKNOWN_ERROR; err=ER(sql_errno); /* purecov: inspected */ } } - orig_err= err; + } + + if (generate_warning) + { + /* Error that we have not got with my_error() */ + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, err); } #ifdef EMBEDDED_LIBRARY @@ -131,8 +139,6 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) } VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length)); #endif /* EMBEDDED_LIBRARY*/ - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, - orig_err ? orig_err : ER(sql_errno)); thd->is_fatal_error=0; // Error message is given thd->net.report_error= 0; diff --git a/sql/slave.cc b/sql/slave.cc index 629a4590858..9849feaf6fa 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1556,7 +1556,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, save_db = thd->db; save_db_length= thd->db_length; thd->db = (char*)db; - DBUG_ASSERT(thd->db); + DBUG_ASSERT(thd->db != 0); thd->db_length= strlen(thd->db); mysql_parse(thd, thd->query, packet_len); // run create table thd->db = save_db; // leave things the way the were before @@ -4031,7 +4031,7 @@ static int queue_binlog_ver_1_event(MASTER_INFO *mi, const char *buf, */ { /* We come here when and only when tmp_buf != 0 */ - DBUG_ASSERT(tmp_buf); + DBUG_ASSERT(tmp_buf != 0); inc_pos=event_len; ev->log_pos+= inc_pos; int error = process_io_create_file(mi,(Create_file_log_event*)ev); diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 3ae7c05c4d6..7176498f276 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -105,7 +105,6 @@ sp_pcontext::diff_handlers(sp_pcontext *ctx) uint sp_pcontext::diff_cursors(sp_pcontext *ctx) { - uint n= 0; sp_pcontext *pctx= this; while (pctx && pctx != ctx) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f3a61b43c34..f5c69269231 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -877,7 +877,6 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, */ int acl_getroot_no_password(THD *thd) { - ulong user_access= NO_ACCESS; int res= 1; uint i; ACL_USER *acl_user= 0; @@ -1660,7 +1659,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, Check that the user isn't trying to change a password for another user if he doesn't have UPDATE privilege to the MySQL database */ - DBUG_ASSERT(combo.host.str); + DBUG_ASSERT(combo.host.str != 0); if (thd->user && combo.password.str && (strcmp(thd->user,combo.user.str) || my_strcasecmp(system_charset_info, @@ -2634,7 +2633,6 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, { class LEX_COLUMN *column; List_iterator <LEX_COLUMN> column_iter(columns); - int res; if (open_and_lock_tables(thd, table_list)) DBUG_RETURN(TRUE); @@ -3473,7 +3471,6 @@ bool check_grant_all_columns(THD *thd, ulong want_access, GRANT_INFO *grant, { GRANT_TABLE *grant_table; GRANT_COLUMN *grant_column; - Field *field=0; want_access &= ~grant->privilege; if (!want_access) @@ -4796,7 +4793,6 @@ static void append_user(String *str, LEX_USER *user) bool mysql_create_user(THD *thd, List <LEX_USER> &list) { int result; - int found; String wrong_users; ulong sql_mode; LEX_USER *user_name; @@ -4817,7 +4813,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list) Search all in-memory structures and grant tables for a mention of the new user name. */ - if ((found= handle_grant_data(tables, 0, user_name, NULL))) + if (handle_grant_data(tables, 0, user_name, NULL)) { append_user(&wrong_users, user_name); result= TRUE; @@ -4859,7 +4855,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list) bool mysql_drop_user(THD *thd, List <LEX_USER> &list) { int result; - int found; String wrong_users; LEX_USER *user_name; List_iterator <LEX_USER> user_list(list); @@ -4875,7 +4870,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list) while ((user_name= user_list++)) { - if ((found= handle_grant_data(tables, 1, user_name, NULL)) <= 0) + if (handle_grant_data(tables, 1, user_name, NULL) <= 0) { append_user(&wrong_users, user_name); result= TRUE; @@ -4907,7 +4902,6 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list) bool mysql_rename_user(THD *thd, List <LEX_USER> &list) { int result= 0; - int found; String wrong_users; LEX_USER *user_from; LEX_USER *user_to; @@ -4925,7 +4919,7 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list) while ((user_from= user_list++)) { user_to= user_list++; - DBUG_ASSERT(user_to); /* Syntax enforces pairs of users. */ + DBUG_ASSERT(user_to != 0); /* Syntax enforces pairs of users. */ /* Search all in-memory structures and grant tables @@ -5137,7 +5131,6 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name) { uint counter, revoked; int result; - ACL_DB *acl_db; TABLE_LIST tables[GRANT_TABLES]; DBUG_ENTER("sp_revoke_privileges"); @@ -5148,10 +5141,10 @@ bool sp_revoke_privileges(THD *thd, const char *sp_db, const char *sp_name) VOID(pthread_mutex_lock(&acl_cache->lock)); /* Remove procedure access */ - do { + do + { for (counter= 0, revoked= 0 ; counter < proc_priv_hash.records ; ) { - const char *db,*name; GRANT_NAME *grant_proc= (GRANT_NAME*) hash_element(&proc_priv_hash, counter); if (!my_strcasecmp(system_charset_info, grant_proc->db, sp_db) && diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 642de13039e..1056bff4315 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -467,7 +467,7 @@ void field_real::add() void field_decimal::add() { my_decimal dec_buf, *dec= item->val_decimal(&dec_buf); - uint length, zero_count, decs; + uint length; TREE_ELEMENT *element; if (item->null_value) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 68a43f71e55..6b75fd1847b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -149,7 +149,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild) TABLE *entry=(TABLE*) hash_element(&open_cache,idx); TABLE_SHARE *share= entry->s; - DBUG_ASSERT(share->table_name); + DBUG_ASSERT(share->table_name != 0); if ((!share->table_name)) // To be removed continue; // Shouldn't happen if (wild) @@ -962,7 +962,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, } else { - DBUG_ASSERT(table_list->view); + DBUG_ASSERT(table_list->view != 0); VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(0); // VIEW } @@ -1188,7 +1188,7 @@ bool reopen_table(TABLE *table,bool locked) table->s= &table->share_not_to_be_used; table->file->change_table_ptr(table); - DBUG_ASSERT(table->alias); + DBUG_ASSERT(table->alias != 0); for (field=table->field ; *field ; field++) { (*field)->table= (*field)->orig_table= table; @@ -2781,7 +2781,6 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, { reg2 Item *item; List_iterator<Item> it(fields); - SELECT_LEX *select_lex= thd->lex->current_select; DBUG_ENTER("setup_fields"); thd->set_query_id=set_query_id; @@ -2839,7 +2838,7 @@ TABLE_LIST **make_leaves_list(TABLE_LIST **list, TABLE_LIST *tables) if (table->view && !table->table) { /* it is for multi table views only, check it */ - DBUG_ASSERT(table->ancestor->next_local); + DBUG_ASSERT(table->ancestor->next_local != 0); list= make_leaves_list(list, table->ancestor); } else @@ -3255,7 +3254,6 @@ err: int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds) { - table_map not_null_tables= 0; SELECT_LEX *select_lex= thd->lex->current_select; Item_arena *arena= thd->current_arena, backup; bool save_wrapper= thd->lex->current_select->no_wrap_view_item; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7dfb7a99ab3..eb98b96c9ec 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -204,7 +204,7 @@ THD::THD() #endif net.last_error[0]=0; // If error on boot ull=0; - system_thread= cleanup_done= abort_on_warning= 0; + system_thread= cleanup_done= abort_on_warning= no_warnings_for_error= 0; peer_port= 0; // For SHOW PROCESSLIST #ifdef __WIN__ real_id = 0; diff --git a/sql/sql_class.h b/sql/sql_class.h index fa28750721c..6c1280366f4 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1186,6 +1186,7 @@ public: bool slow_command; bool no_trans_update, abort_on_warning; bool got_warning; /* Set on call to push_warning() */ + bool no_warnings_for_error; /* no warnings on call to my_error() */ longlong row_count_func; /* For the ROW_COUNT() function */ sp_rcontext *spcont; // SP runtime context sp_cache *sp_proc_cache; @@ -1638,7 +1639,6 @@ public: class select_union :public select_result_interceptor { public: TABLE *table; - COPY_INFO info; TMP_TABLE_PARAM tmp_table_param; select_union(TABLE *table_par); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index c0b74d24d83..64061ab8978 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -773,11 +773,10 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, file->name[2] == 'c' && file->name[3] == '\0') { /* .frm archive */ - char newpath[FN_REFLEN], *copy_of_path; + char newpath[FN_REFLEN]; MY_DIR *new_dirp; - uint length; strxmov(newpath, org_path, "/", "arc", NullS); - length= unpack_filename(newpath, newpath); + (void) unpack_filename(newpath, newpath); if ((new_dirp = my_dir(newpath, MYF(MY_DONT_SORT)))) { DBUG_PRINT("my",("Archive subdir found: %s", newpath)); diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 79f7579d311..4d254b95514 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -106,8 +106,9 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, MYSQL_ERROR *err= 0; DBUG_ENTER("push_warning"); - if (level == MYSQL_ERROR::WARN_LEVEL_NOTE && !(thd->options & OPTION_SQL_NOTES)) - return(0); + if (level == MYSQL_ERROR::WARN_LEVEL_NOTE && + !(thd->options & OPTION_SQL_NOTES)) + DBUG_RETURN(0); if (thd->query_id != thd->warn_id) mysql_reset_errors(thd); @@ -126,9 +127,14 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, if ((int) level >= (int) MYSQL_ERROR::WARN_LEVEL_WARN && thd->really_abort_on_warning()) { + /* Avoid my_message() calling push_warning */ + bool no_warnings_for_error= thd->no_warnings_for_error; + thd->no_warnings_for_error= 1; thd->killed= THD::KILL_BAD_DATA; my_message(code, msg, MYF(0)); - DBUG_RETURN(NULL); + thd->no_warnings_for_error= no_warnings_for_error; + /* Store error in error list (as my_message() didn't do it in this case */ + level= MYSQL_ERROR::WARN_LEVEL_ERROR; } if (thd->warn_list.elements < thd->variables.max_error_count) diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 759b535da53..f5490da7e85 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -640,7 +640,7 @@ bool mysqld_help(THD *thd, const char *mask) List<String> topics_list, categories_list, subcategories_list; String name, description, example; - int res, count_topics, count_categories, error; + int count_topics, count_categories, error; uint mlen= strlen(mask); MEM_ROOT *mem_root= thd->mem_root; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 892e7746353..e08838886ae 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1726,7 +1726,6 @@ bool mysql_insert_select_prepare(THD *thd) { LEX *lex= thd->lex; TABLE_LIST *first_select_leaf_table; - int res; DBUG_ENTER("mysql_insert_select_prepare"); /* SELECT_LEX do not belong to INSERT statement, so we can't add WHERE @@ -1744,7 +1743,7 @@ bool mysql_insert_select_prepare(THD *thd) exclude first table from leaf tables list, because it belong to INSERT */ - DBUG_ASSERT(lex->select_lex.leaf_tables); + DBUG_ASSERT(lex->select_lex.leaf_tables != 0); lex->leaf_tables_insert= lex->select_lex.leaf_tables; /* skip all leaf tables belonged to view where we are insert */ for (first_select_leaf_table= lex->select_lex.leaf_tables->next_leaf; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index efd914003dc..174ccdfab5b 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -104,7 +104,6 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, */ char *tdb= thd->db ? thd->db : db; // Result is never null ulong skip_lines= ex->skip_lines; - int res; bool transactional_table; DBUG_ENTER("mysql_load"); @@ -144,8 +143,6 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, { // Part field list thd->dupp_field=0; /* TODO: use this conds for 'WITH CHECK OPTIONS' */ - Item *unused_conds= 0; - TABLE_LIST *leaves= 0; if (setup_fields(thd, 0, table_list, fields, 1, 0, 0)) DBUG_RETURN(TRUE); if (thd->dupp_field) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9a78daa1479..207803af280 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -622,7 +622,6 @@ bool is_update_query(enum enum_sql_command command) static void time_out_user_resource_limits(THD *thd, USER_CONN *uc) { - bool error= 0; time_t check_time = thd->start_time ? thd->start_time : time(NULL); DBUG_ENTER("time_out_user_resource_limits"); @@ -1330,7 +1329,6 @@ int end_trans(THD *thd, enum enum_mysql_completiontype completion) { bool do_release= 0; int res= 0; - LEX *lex= thd->lex; DBUG_ENTER("end_trans"); switch (completion) { @@ -1901,9 +1899,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { statistic_increment(thd->status_var.com_stat[SQLCOM_DROP_DB], &LOCK_status); - char *db=thd->strdup(packet), *alias; + char *db=thd->strdup(packet); /* null test to handle EOM */ - if (!db || !(alias= thd->strdup(db)) || check_db_name(db)) + if (!db || check_db_name(db)) { my_error(ER_WRONG_DB_NAME, MYF(0), db ? db : "NULL"); break; @@ -3573,8 +3571,7 @@ unsent_create_error: } case SQLCOM_DROP_DB: { - char *alias; - if (!(alias=thd->strdup(lex->name)) || check_db_name(lex->name)) + if (check_db_name(lex->name)) { my_error(ER_WRONG_DB_NAME, MYF(0), lex->name); break; @@ -4023,7 +4020,7 @@ unsent_create_error: char *name, *db; int result; - DBUG_ASSERT(lex->sphead); + DBUG_ASSERT(lex->sphead != 0); if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0)) { diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 93197b1a2eb..7da5c13e18a 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -849,7 +849,7 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt, varname= var_it++; if (get_var_with_binlog(stmt->thd, *varname, &entry)) DBUG_RETURN(1); - DBUG_ASSERT(entry); + DBUG_ASSERT(entry != 0); if (param->set_from_user_var(stmt->thd, entry)) DBUG_RETURN(1); @@ -1008,7 +1008,7 @@ static int mysql_test_update(Prepared_statement *stmt, { if (table_list->ancestor && table_list->ancestor->next_local) { - DBUG_ASSERT(table_list->view); + DBUG_ASSERT(table_list->view != 0); DBUG_PRINT("info", ("Switch to multi-update")); /* pass counter value */ thd->lex->table_count= table_count; @@ -1661,7 +1661,6 @@ error: static bool init_param_array(Prepared_statement *stmt) { LEX *lex= stmt->lex; - THD *thd= stmt->thd; if ((stmt->param_count= lex->param_list.elements)) { if (stmt->param_count > (uint) UINT_MAX16) @@ -2165,7 +2164,6 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) ulong stmt_id= uint4korr(packet); ulong num_rows= uint4korr(packet+=4); Statement *stmt; - int error; DBUG_ENTER("mysql_stmt_fetch"); if (!(stmt= thd->stmt_map.find(stmt_id)) || @@ -2183,7 +2181,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) my_pthread_setprio(pthread_self(), QUERY_PRIOR); thd->protocol= &thd->protocol_prep; // Switch to binary protocol - error= stmt->cursor->fetch(num_rows); + (void) stmt->cursor->fetch(num_rows); thd->protocol= &thd->protocol_simple; // Use normal protocol if (!(specialflag & SPECIAL_NO_PRIOR)) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2f459d40de7..2c1d5f03aa2 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1940,7 +1940,6 @@ Cursor::close() { DBUG_ASSERT(lock || open_tables || derived_tables); - TABLE *tmp_open_tables= thd->open_tables; TABLE *tmp_derived_tables= thd->derived_tables; MYSQL_LOCK *tmp_lock= thd->lock; @@ -7743,7 +7742,6 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case Item::SUM_FUNC_ITEM: { Item_sum *item_sum=(Item_sum*) item; - bool maybe_null=item_sum->maybe_null; Field *result= item_sum->create_tmp_field(group, table, convert_blob_length); if (!result) thd->fatal_error(); @@ -8884,12 +8882,10 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) int error; JOIN_TAB *first_unmatched; JOIN_TAB *tab; - bool found= 0; /* Cache variables for faster loop */ COND *select_cond= join_tab->select_cond; - JOIN_TAB *first_inner_tab= join_tab->first_inner; - my_bool *report_error= &(join->thd->net.report_error); + join->return_tab= join_tab; if (join_tab->last_inner) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8bf6f36ccdc..1339b5e5ed0 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -341,7 +341,6 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) Protocol *protocol= thd->protocol; char buff[2048]; String buffer(buff, sizeof(buff), system_charset_info); - int res; DBUG_ENTER("mysqld_show_create"); DBUG_PRINT("enter",("db: %s table: %s",table_list->db, table_list->table_name)); @@ -535,7 +534,6 @@ void mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild) { TABLE *table; - int res; DBUG_ENTER("mysqld_list_fields"); DBUG_PRINT("enter",("table: %s",table_list->table_name)); @@ -1951,7 +1949,7 @@ void store_schema_shemata(TABLE *table, const char *db_name, int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) { - char path[FN_REFLEN],*end; + char path[FN_REFLEN]; bool found_libchar; INDEX_FIELD_VALUES idx_field_vals; List<char> files; @@ -1960,14 +1958,15 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) bool with_i_schema; HA_CREATE_INFO create; TABLE *table= tables->table; + DBUG_ENTER("fill_schema_shemata"); get_index_field_values(thd->lex, &idx_field_vals); /* information schema name always is first in list */ if (schema_db_add(thd, &files, idx_field_vals.db_value, &with_i_schema)) - return 1; + DBUG_RETURN(1); if (mysql_find_files(thd, &files, NullS, mysql_data_home, idx_field_vals.db_value, 1)) - return 1; + DBUG_RETURN(1); List_iterator_fast<char> it(files); while ((file_name=it++)) { @@ -2000,7 +1999,7 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) create.default_table_charset->csname); } } - return 0; + DBUG_RETURN(0); } @@ -2192,7 +2191,6 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, const char *base_name, const char *file_name) { - TIME time; LEX *lex= thd->lex; const char *wild= lex->wild ? lex->wild->ptr() : NullS; CHARSET_INFO *cs= system_charset_info; @@ -2224,14 +2222,12 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, if (!wild || !wild[0] || !wild_case_compare(system_charset_info, field->field_name,wild)) { - uint tmp_length; const char *tmp_buff; byte *pos; uint flags=field->flags; char tmp[MAX_FIELD_WIDTH]; char tmp1[MAX_FIELD_WIDTH]; String type(tmp,sizeof(tmp), system_charset_info); - char tmp_buffer[128]; count++; restore_record(table, s->default_values); table->field[1]->store(base_name, strlen(base_name), cs); @@ -2338,7 +2334,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":""); table->field[15]->store((const char*) pos, strlen((const char*) pos), cs); - char *end=tmp; + char *end= tmp; if (field->unireg_check == Field::NEXT_NUMBER) end=strmov(tmp,"auto_increment"); table->field[16]->store(tmp, (uint) (end-tmp), cs); @@ -2443,7 +2439,6 @@ int fill_schema_collation(THD *thd, TABLE_LIST *tables, COND *cond) int fill_schema_coll_charset_app(THD *thd, TABLE_LIST *tables, COND *cond) { CHARSET_INFO **cs; - const char *wild= NullS; TABLE *table= tables->table; CHARSET_INFO *scs= system_charset_info; for ( cs= all_charsets ; cs < all_charsets+255 ; cs++ ) @@ -2796,7 +2791,6 @@ static int get_schema_key_column_usage_record(THD *thd, const char *file_name) { DBUG_ENTER("get_schema_key_column_usage_record"); - CHARSET_INFO *cs= system_charset_info; if (res) { if (!tables->view) @@ -2822,7 +2816,6 @@ static int get_schema_key_column_usage_record(THD *thd, KEY_PART_INFO *key_part= key_info->key_part; for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) { - uint f_idx= 0; if (key_part->field) { f_idx++; @@ -2843,13 +2836,13 @@ static int get_schema_key_column_usage_record(THD *thd, List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list); while ((f_key_info= it++)) { - LEX_STRING *f_info, *r_info; + LEX_STRING *f_info; List_iterator_fast<LEX_STRING> it(f_key_info->foreign_fields), it1(f_key_info->referenced_fields); uint f_idx= 0; while ((f_info= it++)) { - r_info= it1++; + it1++; // Ignore r_info f_idx++; restore_record(table, s->default_values); store_key_column_usage(table, base_name, file_name, @@ -3335,11 +3328,13 @@ int make_schema_select(THD *thd, SELECT_LEX *sel, bool get_schema_tables_result(JOIN *join) { - DBUG_ENTER("get_schema_tables_result"); JOIN_TAB *tmp_join_tab= join->join_tab+join->tables; THD *thd= join->thd; LEX *lex= thd->lex; bool result= 0; + DBUG_ENTER("get_schema_tables_result"); + + thd->no_warnings_for_error= 1; for (JOIN_TAB *tab= join->join_tab; tab < tmp_join_tab; tab++) { if (!tab->table || !tab->table->pos_in_table_list) @@ -3376,6 +3371,7 @@ bool get_schema_tables_result(JOIN *join) lex->query_tables_last= query_tables_last; } } + thd->no_warnings_for_error= 0; DBUG_RETURN(result); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b38014eb4ea..7ab1a0a3777 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -191,6 +191,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, if (lock_table_names(thd, tables)) DBUG_RETURN(1); + /* Don't give warnings for not found errors, as we already generate notes */ + thd->no_warnings_for_error= 1; + for (table= tables; table; table= table->next_local) { char *db=table->db; @@ -213,7 +216,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } drop_locked_tables(thd,db,table->table_name); if (thd->killed) + { + thd->no_warnings_for_error= 0; DBUG_RETURN(-1); + } alias= (lower_case_table_names == 2) ? table->alias : table->table_name; /* remove form file and isam files */ strxmov(path, mysql_data_home, "/", db, "/", alias, reg_ext, NullS); @@ -286,6 +292,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } unlock_table_names(thd, tables); + thd->no_warnings_for_error= 0; DBUG_RETURN(error); } @@ -681,7 +688,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, it.rewind(); while ((sql_field=it++)) { - DBUG_ASSERT(sql_field->charset); + DBUG_ASSERT(sql_field->charset != 0); switch (sql_field->sql_type) { case FIELD_TYPE_BLOB: @@ -1955,6 +1962,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, const char *operator_name, thr_lock_type lock_type, bool open_for_modify, + bool no_warnings_for_error, uint extra_open_options, int (*prepare_func)(THD *, TABLE_LIST *, HA_CHECK_OPT *), @@ -1994,7 +2002,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, /* open only one table from local list of command */ next_global_table= table->next_global; table->next_global= 0; + thd->no_warnings_for_error= no_warnings_for_error; open_and_lock_tables(thd, table); + thd->no_warnings_for_error= 0; table->next_global= next_global_table; /* if view are unsupported */ if (table->view && !view_operator_func) @@ -2218,7 +2228,7 @@ bool mysql_backup_table(THD* thd, TABLE_LIST* table_list) { DBUG_ENTER("mysql_backup_table"); DBUG_RETURN(mysql_admin_table(thd, table_list, 0, - "backup", TL_READ, 0, 0, 0, + "backup", TL_READ, 0, 0, 0, 0, &handler::backup, 0)); } @@ -2227,7 +2237,7 @@ bool mysql_restore_table(THD* thd, TABLE_LIST* table_list) { DBUG_ENTER("mysql_restore_table"); DBUG_RETURN(mysql_admin_table(thd, table_list, 0, - "restore", TL_WRITE, 1, 0, + "restore", TL_WRITE, 1, 1, 0, &prepare_for_restore, &handler::restore, 0)); } @@ -2237,7 +2247,9 @@ bool mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) { DBUG_ENTER("mysql_repair_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, - "repair", TL_WRITE, 1, HA_OPEN_FOR_REPAIR, + "repair", TL_WRITE, 1, + test(check_opt->sql_flags & TT_USEFRM), + HA_OPEN_FOR_REPAIR, &prepare_for_repair, &handler::repair, 0)); } @@ -2247,7 +2259,7 @@ bool mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) { DBUG_ENTER("mysql_optimize_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, - "optimize", TL_WRITE, 1,0,0, + "optimize", TL_WRITE, 1,0,0,0, &handler::optimize, 0)); } @@ -2283,7 +2295,7 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, pthread_mutex_unlock(&LOCK_global_system_variables); check_opt.key_cache= key_cache; DBUG_RETURN(mysql_admin_table(thd, tables, &check_opt, - "assign_to_keycache", TL_READ_NO_INSERT, 0, + "assign_to_keycache", TL_READ_NO_INSERT, 0, 0, 0, 0, &handler::assign_to_keycache, 0)); } @@ -2344,7 +2356,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables) { DBUG_ENTER("mysql_preload_keys"); DBUG_RETURN(mysql_admin_table(thd, tables, 0, - "preload_keys", TL_READ, 0, 0, 0, + "preload_keys", TL_READ, 0, 0, 0, 0, &handler::preload_keys, 0)); } @@ -2510,7 +2522,7 @@ bool mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) DBUG_ENTER("mysql_analyze_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, - "analyze", lock_type, 1,0,0, + "analyze", lock_type, 1, 0, 0, 0, &handler::analyze, 0)); } @@ -2526,7 +2538,7 @@ bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) DBUG_ENTER("mysql_check_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, "check", lock_type, - 0, HA_OPEN_FOR_REPAIR, 0, + 0, HA_OPEN_FOR_REPAIR, 0, 0, &handler::check, &view_checksum)); } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 29897c70023..455c83e1718 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -49,12 +49,6 @@ bool mysql_union(THD *thd, LEX *lex, select_result *result, select_union::select_union(TABLE *table_par) :table(table_par) { - bzero((char*) &info,sizeof(info)); - /* - We can always use IGNORE because the temporary table will only - contain a unique key if we are using not using UNION ALL - */ - info.ignore= 1; } select_union::~select_union() @@ -71,22 +65,21 @@ int select_union::prepare(List<Item> &list, SELECT_LEX_UNIT *u) bool select_union::send_data(List<Item> &values) { + int error= 0; if (unit->offset_limit_cnt) { // using limit offset,count unit->offset_limit_cnt--; return 0; } fill_record(thd, table->field, values, 1); - if (thd->net.report_error || write_record(thd, table,&info)) + if (thd->net.report_error) + return 1; + + if ((error= table->file->write_row(table->record[0]))) { - if (thd->net.last_errno == ER_RECORD_FILE_FULL) - { - thd->clear_error(); // do not report user about table overflow - if (create_myisam_from_heap(thd, table, &tmp_table_param, - info.last_errno, 1)) - return 1; - } - else + /* create_myisam_from_heap will generate error if needed */ + if (error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE && + create_myisam_from_heap(thd, table, &tmp_table_param, error, 1)) return 1; } return 0; @@ -386,7 +379,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, for (Field **field= table->field; *field; field++) { Item_field *item_field= (Item_field*) it++; - DBUG_ASSERT(item_field); + DBUG_ASSERT(item_field != 0); item_field->reset_field(*field); } } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 80ad13195c8..54a976fe2b0 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -141,7 +141,7 @@ int mysql_update(THD *thd, if (table_list->ancestor && table_list->ancestor->next_local) { - DBUG_ASSERT(table_list->view); + DBUG_ASSERT(table_list->view != 0); DBUG_PRINT("info", ("Switch to multi-update")); /* pass counter value */ thd->lex->table_count= table_count; @@ -191,6 +191,7 @@ int mysql_update(THD *thd, table_list->grant.want_privilege= table->grant.want_privilege= want_privilege; #endif { + bool res; select_lex->no_wrap_view_item= 1; res= setup_fields(thd, 0, table_list, fields, 1, 0, 0); select_lex->no_wrap_view_item= 0; @@ -815,7 +816,6 @@ bool mysql_multi_update(THD *thd, enum enum_duplicates handle_duplicates, bool ignore, SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) { - bool res= FALSE; multi_update *result; DBUG_ENTER("mysql_multi_update"); @@ -834,14 +834,14 @@ bool mysql_multi_update(THD *thd, MODE_STRICT_ALL_TABLES)); List<Item> total_list; - res= mysql_select(thd, &select_lex->ref_pointer_array, - table_list, select_lex->with_wild, - total_list, - conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL, - (ORDER *)NULL, - options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | - OPTION_SETUP_TABLES_DONE, - result, unit, select_lex); + (void) mysql_select(thd, &select_lex->ref_pointer_array, + table_list, select_lex->with_wild, + total_list, + conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL, + (ORDER *)NULL, + options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | + OPTION_SETUP_TABLES_DONE, + result, unit, select_lex); delete result; thd->abort_on_warning= 0; DBUG_RETURN(TRUE); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ba1b999b240..3b03b66c61e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3235,7 +3235,6 @@ alter: } sp_a_chistics { - THD *thd= YYTHD; LEX *lex=Lex; lex->sql_command= SQLCOM_ALTER_PROCEDURE; @@ -3249,7 +3248,6 @@ alter: } sp_a_chistics { - THD *thd= YYTHD; LEX *lex=Lex; lex->sql_command= SQLCOM_ALTER_FUNCTION; @@ -4480,7 +4478,6 @@ simple_expr: { $$= new Item_int((char*) "TRUE",1,1); } | ident '.' ident '(' udf_expr_list ')' { - LEX *lex= Lex; sp_name *name= new sp_name($1, $3); name->init_qname(YYTHD); @@ -6429,24 +6426,24 @@ field_term_list: field_term: TERMINATED BY text_string { - DBUG_ASSERT(Lex->exchange); + DBUG_ASSERT(Lex->exchange != 0); Lex->exchange->field_term= $3; } | OPTIONALLY ENCLOSED BY text_string { LEX *lex= Lex; - DBUG_ASSERT(lex->exchange); + DBUG_ASSERT(lex->exchange != 0); lex->exchange->enclosed= $4; lex->exchange->opt_enclosed= 1; } | ENCLOSED BY text_string { - DBUG_ASSERT(Lex->exchange); + DBUG_ASSERT(Lex->exchange != 0); Lex->exchange->enclosed= $3; } | ESCAPED BY text_string { - DBUG_ASSERT(Lex->exchange); + DBUG_ASSERT(Lex->exchange != 0); Lex->exchange->escaped= $3; }; @@ -6461,12 +6458,12 @@ line_term_list: line_term: TERMINATED BY text_string { - DBUG_ASSERT(Lex->exchange); + DBUG_ASSERT(Lex->exchange != 0); Lex->exchange->line_term= $3; } | STARTING BY text_string { - DBUG_ASSERT(Lex->exchange); + DBUG_ASSERT(Lex->exchange != 0); Lex->exchange->line_start= $3; }; @@ -6474,7 +6471,7 @@ opt_ignore_lines: /* empty */ | IGNORE_SYM NUM LINES { - DBUG_ASSERT(Lex->exchange); + DBUG_ASSERT(Lex->exchange != 0); Lex->exchange->skip_lines= atol($2.str); }; @@ -7306,7 +7303,6 @@ option_value: } | NAMES_SYM charset_name_or_default opt_collate { - THD *thd= YYTHD; LEX *lex= Lex; $2= $2 ? $2 : global_system_variables.character_set_client; $3= $3 ? $3 : $2; diff --git a/sql/strfunc.cc b/sql/strfunc.cc index ca1a4b64af9..c822d10af46 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -147,7 +147,7 @@ uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match) uint find_type2(TYPELIB *typelib, const char *x, uint length, CHARSET_INFO *cs) { - int find,pos; + int pos; const char *j; DBUG_ENTER("find_type2"); DBUG_PRINT("enter",("x: '%.*s' lib: 0x%lx", length, x, typelib)); @@ -158,7 +158,7 @@ uint find_type2(TYPELIB *typelib, const char *x, uint length, CHARSET_INFO *cs) DBUG_RETURN(0); } - for (find=0, pos=0 ; (j=typelib->type_names[pos]) ; pos++) + for (pos=0 ; (j=typelib->type_names[pos]) ; pos++) { if (!my_strnncoll(cs, (const uchar*) x, length, (const uchar*) j, typelib->type_lengths[pos])) diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index a3f96a947a7..797bc9f9047 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -372,7 +372,7 @@ static int my_strnxfrm_ucs2(CHARSET_INFO *cs, dst+=res; } if (dst < de) - cs->cset->fill(cs, dst, de - dst, ' '); + cs->cset->fill(cs, (char*) dst, de - dst, ' '); return dstlen; } @@ -1385,7 +1385,7 @@ int my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), if (dst != src) memcpy(dst,src,srclen= min(dstlen,srclen)); if (dstlen > srclen) - cs->cset->fill(cs, dst + srclen, dstlen - srclen, ' '); + cs->cset->fill(cs, (char*) dst + srclen, dstlen - srclen, ' '); return dstlen; } diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 8f49b45de0c..626b90faf73 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -3351,7 +3351,7 @@ static void test_bind_result() MYSQL_STMT *stmt; int rc; int nData; - ulong length, length1; + ulong length1; char szData[100]; MYSQL_BIND bind[2]; my_bool is_null[2]; @@ -3416,7 +3416,6 @@ static void test_bind_result() DIE_UNLESS(strcmp(szData, "MySQL") == 0); DIE_UNLESS(length1 == 5); - length= 99; rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); @@ -5350,7 +5349,6 @@ static void test_prepare_alter() { MYSQL_STMT *stmt; int rc, id; - long length; MYSQL_BIND bind[1]; my_bool is_null; @@ -5385,7 +5383,6 @@ static void test_prepare_alter() check_execute(stmt, rc); id= 30; - length= 0; rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); @@ -11620,14 +11617,13 @@ static void test_bug6059() { MYSQL_STMT *stmt; const char *stmt_text; - int rc; myheader("test_bug6059"); stmt_text= "SELECT 'foo' INTO OUTFILE 'x.3'"; stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + (void) mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); DIE_UNLESS(mysql_stmt_field_count(stmt) == 0); mysql_stmt_close(stmt); } diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c index 1be0242c505..1ae8f908dc2 100644 --- a/tools/mysqlmanager.c +++ b/tools/mysqlmanager.c @@ -557,14 +557,13 @@ HANDLE_DECL(handle_set_exec_stderr) static int set_exec_param(struct manager_thd* thd, char* args_start, char* args_end, PARAM_TYPE param_type) { - int num_args; const char* error=0; struct manager_exec* e; char* arg_p; char* param; int param_size; - if ((num_args=tokenize_args(args_start,&args_end))<2) + if (tokenize_args(args_start,&args_end) < 2) { error="Too few arguments"; goto err; @@ -607,12 +606,11 @@ err: HANDLE_DECL(handle_start_exec) { - int num_args; struct manager_exec* e; int ident_len; const char* error=0; struct timespec t; - if ((num_args=tokenize_args(args_start,&args_end))<1) + if (tokenize_args(args_start,&args_end) < 1) { error="Too few arguments"; goto err; @@ -656,12 +654,11 @@ err: HANDLE_DECL(handle_stop_exec) { - int num_args; struct timespec abstime; struct manager_exec* e; int ident_len; const char* error=0; - if ((num_args=tokenize_args(args_start,&args_end))<2) + if (tokenize_args(args_start,&args_end) <2) { error="Too few arguments"; goto err; |