diff options
author | unknown <monty@mysql.com> | 2005-02-24 23:33:42 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-02-24 23:33:42 +0200 |
commit | eb18f93a7847ca6cdb8430d4500a797fe68826db (patch) | |
tree | 7dbb7787461bf6040b70c1701768dfa24df638d8 | |
parent | a2a1449c36c8124c808ab207d92a0749346b9d15 (diff) | |
download | mariadb-git-eb18f93a7847ca6cdb8430d4500a797fe68826db.tar.gz |
Show all generated warnings in SHOW ERROR
Previously we only stored the first given error (the error sent to the client)
include/mysys_err.h:
Moved ER_FILENOTFOUND last to avoid getting 'error 0'
mysql-test/r/backup.result:
More warnings from in case of errors
mysql-test/r/innodb.result:
More warnings from in case of errors
mysql-test/r/key_cache.result:
More warnings from in case of errors
mysql-test/r/myisam.result:
More warnings from in case of errors
mysql-test/r/preload.result:
More warnings from in case of errors
mysql-test/r/repair.result:
More warnings from in case of errors
mysql-test/r/rpl_failed_optimize.result:
More warnings from in case of errors
mysql-test/r/subselect.result:
More warnings from in case of errors
mysql-test/t/backup.test:
Portability fix
mysql-test/t/innodb.test:
Avoid some warnings
mysql-test/t/myisam.test:
Portability fix
mysql-test/t/rpl_rotate_logs.test:
Portablitiy fix
mysys/errors.c:
Move ER_FILENOTFOUND last to avoid error 0
sql/mysql_priv.h:
Indentation change
sql/mysqld.cc:
Save all given errors for SHOW ERRORS
sql/protocol.cc:
Store new errors for SHOW ERROR
(Ignore those that are already reported with my_error())
sql/sql_class.cc:
More errors with SHOW ERROR
sql/sql_class.h:
More errors with SHOW ERROR
sql/sql_error.cc:
More errors with SHOW ERROR
sql/sql_parse.cc:
Temporary fix: Don't give error for the to-be-removed 'pre-open tables code'
sql/sql_show.cc:
More debugging
Don't register errors while populating schema tables.
(If we do, we get a LOT of warnings from information_schema.test)
sql/sql_table.cc:
Don't register errors from handler in drop table (as we already do it the upper level DROP TABLE code)
Don't register errors for 'restore_table' as in most cases the table doesn't exists
sql/sql_union.cc:
Use file->write_row() instead of 'write_record'.
This gives us easer to handle error messages and is faster than the old version
-rw-r--r-- | include/mysys_err.h | 15 | ||||
-rw-r--r-- | mysql-test/r/backup.result | 6 | ||||
-rw-r--r-- | mysql-test/r/innodb.result | 8 | ||||
-rw-r--r-- | mysql-test/r/key_cache.result | 2 | ||||
-rw-r--r-- | mysql-test/r/myisam.result | 6 | ||||
-rw-r--r-- | mysql-test/r/preload.result | 5 | ||||
-rw-r--r-- | mysql-test/r/repair.result | 4 | ||||
-rw-r--r-- | mysql-test/r/rpl_failed_optimize.result | 4 | ||||
-rw-r--r-- | mysql-test/r/subselect.result | 2 | ||||
-rw-r--r-- | mysql-test/t/backup.test | 5 | ||||
-rw-r--r-- | mysql-test/t/innodb.test | 4 | ||||
-rw-r--r-- | mysql-test/t/myisam.test | 2 | ||||
-rw-r--r-- | mysql-test/t/rpl_rotate_logs.test | 2 | ||||
-rw-r--r-- | mysys/errors.c | 5 | ||||
-rw-r--r-- | sql/mysql_priv.h | 3 | ||||
-rw-r--r-- | sql/mysqld.cc | 4 | ||||
-rw-r--r-- | sql/protocol.cc | 14 | ||||
-rw-r--r-- | sql/sql_class.cc | 2 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_error.cc | 12 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 12 | ||||
-rw-r--r-- | sql/sql_table.cc | 28 | ||||
-rw-r--r-- | sql/sql_union.cc | 23 |
24 files changed, 115 insertions, 57 deletions
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/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 d65ce794a75..fb8d632aed9 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1449,18 +1449,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 6514f3d5c94..970abc184f2 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1054,8 +1054,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 47b5754232c..cbe786acfa9 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/sql/mysql_priv.h b/sql/mysql_priv.h index 7c625c208e1..e204d5daeb5 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -254,8 +254,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 9013a7f5c3d..ed5fbd34ea7 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -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 { diff --git a/sql/protocol.cc b/sql/protocol.cc index b84d170873d..460fa969898 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] ? @@ -79,14 +79,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 @@ -125,8 +133,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/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 2d89ded63c2..5ffdca895bb 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_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_parse.cc b/sql/sql_parse.cc index 3e2915e6e07..63d92ca0e5f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2252,6 +2252,7 @@ mysql_execute_command(THD *thd) lex->sql_command != SQLCOM_LOCK_TABLES && lex->sql_command != SQLCOM_UNLOCK_TABLES) { + thd->no_warnings_for_error= 1; while (1) { if (sp_cache_routines(thd, lex, TYPE_ENUM_FUNCTION)) @@ -2331,6 +2332,7 @@ mysql_execute_command(THD *thd) } break; } // while (1) + thd->no_warnings_for_error= 0; } /* diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 8bf6f36ccdc..ae0b591a403 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1960,14 +1960,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 +2001,7 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) create.default_table_charset->csname); } } - return 0; + DBUG_RETURN(0); } @@ -3335,11 +3336,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 +3379,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..f87a60c4fda 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); } @@ -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..c2d401d3a7f 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; |