Commit eb18f93a authored by unknown's avatar unknown

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
parent a2a1449c
...@@ -26,10 +26,14 @@ extern "C" { ...@@ -26,10 +26,14 @@ extern "C" {
extern const char * NEAR globerrs[]; /* my_error_messages is here */ extern const char * NEAR globerrs[]; /* my_error_messages is here */
/* Error message numbers in global map */ /* 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. */ Do not add error numbers before EE_ERROR_FIRST.
#define EE_ERROR_FIRST 0 /*Copy first error nr.*/ If necessary to add lower numbers, change EE_ERROR_FIRST accordingly.
#define EE_FILENOTFOUND 0
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_CANTCREATEFILE 1
#define EE_READ 2 #define EE_READ 2
#define EE_WRITE 3 #define EE_WRITE 3
...@@ -57,7 +61,8 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */ ...@@ -57,7 +61,8 @@ extern const char * NEAR globerrs[]; /* my_error_messages is here */
#define EE_REALPATH 26 #define EE_REALPATH 26
#define EE_SYNC 27 #define EE_SYNC 27
#define EE_UNKNOWN_COLLATION 28 #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. */ /* Add error numbers before EE_ERROR_LAST and change it accordingly. */
/* exit codes for all MySQL programs */ /* exit codes for all MySQL programs */
......
...@@ -5,6 +5,8 @@ backup table t4 to '../bogus'; ...@@ -5,6 +5,8 @@ backup table t4 to '../bogus';
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t4 backup error Failed copying .frm file (errno: X) test.t4 backup error Failed copying .frm file (errno: X)
test.t4 backup status Operation failed 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'; backup table t4 to '../tmp';
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t4 backup status OK test.t4 backup status OK
...@@ -12,6 +14,8 @@ backup table t4 to '../tmp'; ...@@ -12,6 +14,8 @@ backup table t4 to '../tmp';
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t4 backup error Failed copying .frm file (errno: X) test.t4 backup error Failed copying .frm file (errno: X)
test.t4 backup status Operation failed 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; drop table t4;
restore table t4 from '../tmp'; restore table t4 from '../tmp';
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
...@@ -28,6 +32,8 @@ drop table t1; ...@@ -28,6 +32,8 @@ drop table t1;
restore table t1 from '../bogus'; restore table t1 from '../bogus';
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
t1 restore error Failed copying .frm file 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'; restore table t1 from '../tmp';
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 restore status OK test.t1 restore status OK
......
...@@ -1449,18 +1449,18 @@ test.t1 2948697075 ...@@ -1449,18 +1449,18 @@ test.t1 2948697075
test.t2 NULL test.t2 NULL
test.t3 NULL test.t3 NULL
test.t4 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 Table Checksum
test.t1 2948697075 test.t1 2948697075
test.t2 968604391 test.t2 968604391
test.t3 968604391 test.t3 968604391
test.t4 NULL checksum table t1, t2, t3 extended;
checksum table t1, t2, t3, t4 extended;
Table Checksum Table Checksum
test.t1 3092701434 test.t1 3092701434
test.t2 968604391 test.t2 968604391
test.t3 968604391 test.t3 968604391
test.t4 NULL
drop table t1,t2,t3; drop table t1,t2,t3;
create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb; 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'); insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
......
...@@ -193,6 +193,8 @@ cache index t1 key (unknown_key) in keycache1; ...@@ -193,6 +193,8 @@ cache index t1 key (unknown_key) in keycache1;
Table Op Msg_type Msg_text 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 error Key column 'unknown_key' doesn't exist in table
test.t1 assign_to_keycache status Operation failed 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; select @@keycache2.key_buffer_size;
@@keycache2.key_buffer_size @@keycache2.key_buffer_size
4194304 4194304
......
...@@ -516,16 +516,22 @@ Table Checksum ...@@ -516,16 +516,22 @@ Table Checksum
test.t1 2948697075 test.t1 2948697075
test.t2 NULL test.t2 NULL
test.t3 NULL test.t3 NULL
Warnings:
Error 1146 Table 'test.t3' doesn't exist
checksum table t1, t2, t3; checksum table t1, t2, t3;
Table Checksum Table Checksum
test.t1 2948697075 test.t1 2948697075
test.t2 3092701434 test.t2 3092701434
test.t3 NULL test.t3 NULL
Warnings:
Error 1146 Table 'test.t3' doesn't exist
checksum table t1, t2, t3 extended; checksum table t1, t2, t3 extended;
Table Checksum Table Checksum
test.t1 3092701434 test.t1 3092701434
test.t2 3092701434 test.t2 3092701434
test.t3 NULL test.t3 NULL
Warnings:
Error 1146 Table 'test.t3' doesn't exist
drop table t1,t2; drop table t1,t2;
create table t1 (a int, key (a)); create table t1 (a int, key (a));
show keys from t1; show keys from t1;
......
...@@ -145,6 +145,8 @@ load index into cache t3, t2 key (primary,b) ; ...@@ -145,6 +145,8 @@ load index into cache t3, t2 key (primary,b) ;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t3 preload_keys error Table 'test.t3' doesn't exist test.t3 preload_keys error Table 'test.t3' doesn't exist
test.t2 preload_keys status OK test.t2 preload_keys status OK
Warnings:
Error 1146 Table 'test.t3' doesn't exist
show status like "key_read%"; show status like "key_read%";
Variable_name Value Variable_name Value
Key_read_requests 355 Key_read_requests 355
...@@ -160,6 +162,9 @@ Table Op Msg_type Msg_text ...@@ -160,6 +162,9 @@ Table Op Msg_type Msg_text
test.t3 preload_keys error Table 'test.t3' doesn't exist 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 error Key column 'c' doesn't exist in table
test.t2 preload_keys status Operation failed 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%"; show status like "key_read%";
Variable_name Value Variable_name Value
Key_read_requests 0 Key_read_requests 0
......
...@@ -27,11 +27,15 @@ drop table t1; ...@@ -27,11 +27,15 @@ drop table t1;
repair table t1 use_frm; repair table t1 use_frm;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 repair error Table 'test.t1' doesn't exist 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"; create table t1 engine=myisam SELECT 1,"table 1";
flush tables; flush tables;
repair table t1; repair table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 repair error Incorrect file format 't1' test.t1 repair error Incorrect file format 't1'
Warnings:
Error 130 Incorrect file format 't1'
repair table t1 use_frm; repair table t1 use_frm;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 1 test.t1 repair warning Number of rows changed from 0 to 1
......
...@@ -10,6 +10,10 @@ INSERT INTO t1 VALUES (1); ...@@ -10,6 +10,10 @@ INSERT INTO t1 VALUES (1);
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status Operation failed test.t1 optimize status Operation failed
Warnings:
Error 1205 Lock wait timeout exceeded; try restarting transaction
OPTIMIZE TABLE non_existing; OPTIMIZE TABLE non_existing;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.non_existing optimize error Table 'test.non_existing' doesn't exist test.non_existing optimize error Table 'test.non_existing' doesn't exist
Warnings:
Error 1146 Table 'test.non_existing' doesn't exist
...@@ -1598,6 +1598,8 @@ insert into t1 values (2); ...@@ -1598,6 +1598,8 @@ insert into t1 values (2);
set sort_buffer_size = (select s1 from t1); set sort_buffer_size = (select s1 from t1);
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
do (select * from t1); do (select * from t1);
Warnings:
Error 1242 Subquery returns more than 1 row
drop table t1; drop table t1;
create table t1 (s1 char); create table t1 (s1 char);
insert into t1 values ('e'); insert into t1 values ('e');
......
...@@ -10,10 +10,10 @@ set SQL_LOG_BIN=0; ...@@ -10,10 +10,10 @@ set SQL_LOG_BIN=0;
drop table if exists t1, t2, t3; drop table if exists t1, t2, t3;
--enable_warnings --enable_warnings
create table t4(n int); 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 '../bogus';
backup table t4 to '../tmp'; 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'; backup table t4 to '../tmp';
drop table t4; drop table t4;
restore table t4 from '../tmp'; restore table t4 from '../tmp';
...@@ -23,6 +23,7 @@ create table t1(n int); ...@@ -23,6 +23,7 @@ create table t1(n int);
insert into t1 values (23),(45),(67); insert into t1 values (23),(45),(67);
backup table t1 to '../tmp'; backup table t1 to '../tmp';
drop table t1; 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 '../bogus';
restore table t1 from '../tmp'; restore table t1 from '../tmp';
select n from t1; select n from t1;
......
...@@ -1054,8 +1054,8 @@ insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); ...@@ -1054,8 +1054,8 @@ insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
insert t2 select * from t1; insert t2 select * from t1;
insert t3 select * from t1; insert t3 select * from t1;
checksum table t1, t2, t3, t4 quick; checksum table t1, t2, t3, t4 quick;
checksum table t1, t2, t3, t4; checksum table t1, t2, t3;
checksum table t1, t2, t3, t4 extended; checksum table t1, t2, t3 extended;
#show table status; #show table status;
drop table t1,t2,t3; drop table t1,t2,t3;
......
...@@ -552,7 +552,7 @@ system rm ./var/master-data/test/t1.MYI ; ...@@ -552,7 +552,7 @@ system rm ./var/master-data/test/t1.MYI ;
drop table t1; drop table t1;
create table t1 (a int) engine=myisam; create table t1 (a int) engine=myisam;
system rm ./var/master-data/test/t1.MYD ; system rm ./var/master-data/test/t1.MYD ;
--error 1105,6 --error 1105,6,29
drop table t1; drop table t1;
--error 1051 --error 1051
drop table t1; drop table t1;
...@@ -24,7 +24,7 @@ drop table if exists t1, t2, t3, t4; ...@@ -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) # START SLAVE will fail because it can't read the file (mode 000)
# (system error 13) # (system error 13)
--replace_result $MYSQL_TEST_DIR TESTDIR --replace_result $MYSQL_TEST_DIR TESTDIR
--error 1105,1105 --error 1105,1105,29
start slave; start slave;
system chmod 600 var/slave-data/master.info; system chmod 600 var/slave-data/master.info;
# It will fail again because the file is empty so the slave cannot get valuable # It will fail again because the file is empty so the slave cannot get valuable
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
const char * NEAR globerrs[GLOBERRS]= const char * NEAR globerrs[GLOBERRS]=
{ {
"File '%s' not found (Errcode: %d)",
"Can't create/write to file '%s' (Errcode: %d)", "Can't create/write to file '%s' (Errcode: %d)",
"Error reading file '%s' (Errcode: %d)", "Error reading file '%s' (Errcode: %d)",
"Error writing file '%s' (Errcode: %d)", "Error writing file '%s' (Errcode: %d)",
...@@ -50,6 +49,8 @@ const char * NEAR globerrs[GLOBERRS]= ...@@ -50,6 +49,8 @@ const char * NEAR globerrs[GLOBERRS]=
"Error on realpath() on '%s' (Error %d)", "Error on realpath() on '%s' (Error %d)",
"Can't sync file '%s' to disk (Errcode: %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", "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) void init_glob_errs(void)
...@@ -61,7 +62,6 @@ void init_glob_errs(void) ...@@ -61,7 +62,6 @@ void init_glob_errs(void)
void init_glob_errs() 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_CANTCREATEFILE) = "Can't create/write to file '%s' (Errcode: %d)";
EE(EE_READ) = "Error reading file '%s' (Errcode: %d)"; EE(EE_READ) = "Error reading file '%s' (Errcode: %d)";
EE(EE_WRITE) = "Error writing file '%s' (Errcode: %d)"; EE(EE_WRITE) = "Error writing file '%s' (Errcode: %d)";
...@@ -89,5 +89,6 @@ void init_glob_errs() ...@@ -89,5 +89,6 @@ void init_glob_errs()
EE(EE_REALPATH)= "Error on realpath() on '%s' (Error %d)"; EE(EE_REALPATH)= "Error on realpath() on '%s' (Error %d)";
EE(EE_SYNC)= "Can't sync file '%s' to disk (Errcode: %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_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 #endif
...@@ -254,8 +254,7 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; ...@@ -254,8 +254,7 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
/* The rest of the file is included in the server only */ /* The rest of the file is included in the server only */
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
/* If set to 0, then the thread will ignore all warnings with level notes. /* If not set then the thread will ignore all warnings with level notes. */
Set by executing SET SQL_NOTES=1 */
#define OPTION_SQL_NOTES (1L << 31) #define OPTION_SQL_NOTES (1L << 31)
/* Bits for different SQL modes modes (including ANSI mode) */ /* Bits for different SQL modes modes (including ANSI mode) */
......
...@@ -2228,6 +2228,8 @@ extern "C" int my_message_sql(uint error, const char *str, myf MyFlags) ...@@ -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 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 thd->lex->current_select == 0 if lex structure is not inited
(not query command (COM_QUERY)) (not query command (COM_QUERY))
...@@ -2239,8 +2241,6 @@ extern "C" int my_message_sql(uint error, const char *str, myf MyFlags) ...@@ -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 ?
thd->lex->current_select->no_error : 0), thd->lex->current_select->no_error : 0),
(int) thd->is_fatal_error)); (int) thd->is_fatal_error));
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str);
} }
else else
{ {
......
...@@ -59,8 +59,8 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) ...@@ -59,8 +59,8 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
uint length; uint length;
char buff[MYSQL_ERRMSG_SIZE+2], *pos; char buff[MYSQL_ERRMSG_SIZE+2], *pos;
#endif #endif
const char *orig_err= err;
NET *net= &thd->net; NET *net= &thd->net;
bool generate_warning= 1;
DBUG_ENTER("net_send_error"); DBUG_ENTER("net_send_error");
DBUG_PRINT("enter",("sql_errno: %d err: %s", sql_errno, DBUG_PRINT("enter",("sql_errno: %d err: %s", sql_errno,
err ? err : net->last_error[0] ? err ? err : net->last_error[0] ?
...@@ -79,14 +79,22 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) ...@@ -79,14 +79,22 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
else else
{ {
if ((err=net->last_error)[0]) if ((err=net->last_error)[0])
{
sql_errno=net->last_errno; sql_errno=net->last_errno;
generate_warning= 0; // This warning has already been given
}
else else
{ {
sql_errno=ER_UNKNOWN_ERROR; sql_errno=ER_UNKNOWN_ERROR;
err=ER(sql_errno); /* purecov: inspected */ 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 #ifdef EMBEDDED_LIBRARY
...@@ -125,8 +133,6 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) ...@@ -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)); VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length));
#endif /* EMBEDDED_LIBRARY*/ #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->is_fatal_error=0; // Error message is given
thd->net.report_error= 0; thd->net.report_error= 0;
......
...@@ -204,7 +204,7 @@ THD::THD() ...@@ -204,7 +204,7 @@ THD::THD()
#endif #endif
net.last_error[0]=0; // If error on boot net.last_error[0]=0; // If error on boot
ull=0; 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 peer_port= 0; // For SHOW PROCESSLIST
#ifdef __WIN__ #ifdef __WIN__
real_id = 0; real_id = 0;
......
...@@ -1186,6 +1186,7 @@ public: ...@@ -1186,6 +1186,7 @@ public:
bool slow_command; bool slow_command;
bool no_trans_update, abort_on_warning; bool no_trans_update, abort_on_warning;
bool got_warning; /* Set on call to push_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 */ longlong row_count_func; /* For the ROW_COUNT() function */
sp_rcontext *spcont; // SP runtime context sp_rcontext *spcont; // SP runtime context
sp_cache *sp_proc_cache; sp_cache *sp_proc_cache;
...@@ -1638,7 +1639,6 @@ public: ...@@ -1638,7 +1639,6 @@ public:
class select_union :public select_result_interceptor { class select_union :public select_result_interceptor {
public: public:
TABLE *table; TABLE *table;
COPY_INFO info;
TMP_TABLE_PARAM tmp_table_param; TMP_TABLE_PARAM tmp_table_param;
select_union(TABLE *table_par); select_union(TABLE *table_par);
......
...@@ -106,8 +106,9 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, ...@@ -106,8 +106,9 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
MYSQL_ERROR *err= 0; MYSQL_ERROR *err= 0;
DBUG_ENTER("push_warning"); DBUG_ENTER("push_warning");
if (level == MYSQL_ERROR::WARN_LEVEL_NOTE && !(thd->options & OPTION_SQL_NOTES)) if (level == MYSQL_ERROR::WARN_LEVEL_NOTE &&
return(0); !(thd->options & OPTION_SQL_NOTES))
DBUG_RETURN(0);
if (thd->query_id != thd->warn_id) if (thd->query_id != thd->warn_id)
mysql_reset_errors(thd); mysql_reset_errors(thd);
...@@ -126,9 +127,14 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, ...@@ -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 && if ((int) level >= (int) MYSQL_ERROR::WARN_LEVEL_WARN &&
thd->really_abort_on_warning()) 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; thd->killed= THD::KILL_BAD_DATA;
my_message(code, msg, MYF(0)); 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) if (thd->warn_list.elements < thd->variables.max_error_count)
......
...@@ -2252,6 +2252,7 @@ mysql_execute_command(THD *thd) ...@@ -2252,6 +2252,7 @@ mysql_execute_command(THD *thd)
lex->sql_command != SQLCOM_LOCK_TABLES && lex->sql_command != SQLCOM_LOCK_TABLES &&
lex->sql_command != SQLCOM_UNLOCK_TABLES) lex->sql_command != SQLCOM_UNLOCK_TABLES)
{ {
thd->no_warnings_for_error= 1;
while (1) while (1)
{ {
if (sp_cache_routines(thd, lex, TYPE_ENUM_FUNCTION)) if (sp_cache_routines(thd, lex, TYPE_ENUM_FUNCTION))
...@@ -2331,6 +2332,7 @@ mysql_execute_command(THD *thd) ...@@ -2331,6 +2332,7 @@ mysql_execute_command(THD *thd)
} }
break; break;
} // while (1) } // while (1)
thd->no_warnings_for_error= 0;
} }
/* /*
......
...@@ -1960,14 +1960,15 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -1960,14 +1960,15 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
bool with_i_schema; bool with_i_schema;
HA_CREATE_INFO create; HA_CREATE_INFO create;
TABLE *table= tables->table; TABLE *table= tables->table;
DBUG_ENTER("fill_schema_shemata");
get_index_field_values(thd->lex, &idx_field_vals); get_index_field_values(thd->lex, &idx_field_vals);
/* information schema name always is first in list */ /* information schema name always is first in list */
if (schema_db_add(thd, &files, idx_field_vals.db_value, &with_i_schema)) 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, if (mysql_find_files(thd, &files, NullS, mysql_data_home,
idx_field_vals.db_value, 1)) idx_field_vals.db_value, 1))
return 1; DBUG_RETURN(1);
List_iterator_fast<char> it(files); List_iterator_fast<char> it(files);
while ((file_name=it++)) while ((file_name=it++))
{ {
...@@ -2000,7 +2001,7 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -2000,7 +2001,7 @@ int fill_schema_shemata(THD *thd, TABLE_LIST *tables, COND *cond)
create.default_table_charset->csname); create.default_table_charset->csname);
} }
} }
return 0; DBUG_RETURN(0);
} }
...@@ -3335,11 +3336,13 @@ int make_schema_select(THD *thd, SELECT_LEX *sel, ...@@ -3335,11 +3336,13 @@ int make_schema_select(THD *thd, SELECT_LEX *sel,
bool get_schema_tables_result(JOIN *join) bool get_schema_tables_result(JOIN *join)
{ {
DBUG_ENTER("get_schema_tables_result");
JOIN_TAB *tmp_join_tab= join->join_tab+join->tables; JOIN_TAB *tmp_join_tab= join->join_tab+join->tables;
THD *thd= join->thd; THD *thd= join->thd;
LEX *lex= thd->lex; LEX *lex= thd->lex;
bool result= 0; 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++) for (JOIN_TAB *tab= join->join_tab; tab < tmp_join_tab; tab++)
{ {
if (!tab->table || !tab->table->pos_in_table_list) if (!tab->table || !tab->table->pos_in_table_list)
...@@ -3376,6 +3379,7 @@ bool get_schema_tables_result(JOIN *join) ...@@ -3376,6 +3379,7 @@ bool get_schema_tables_result(JOIN *join)
lex->query_tables_last= query_tables_last; lex->query_tables_last= query_tables_last;
} }
} }
thd->no_warnings_for_error= 0;
DBUG_RETURN(result); DBUG_RETURN(result);
} }
......
...@@ -191,6 +191,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -191,6 +191,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
if (lock_table_names(thd, tables)) if (lock_table_names(thd, tables))
DBUG_RETURN(1); 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) for (table= tables; table; table= table->next_local)
{ {
char *db=table->db; char *db=table->db;
...@@ -213,7 +216,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -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); drop_locked_tables(thd,db,table->table_name);
if (thd->killed) if (thd->killed)
{
thd->no_warnings_for_error= 0;
DBUG_RETURN(-1); DBUG_RETURN(-1);
}
alias= (lower_case_table_names == 2) ? table->alias : table->table_name; alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
/* remove form file and isam files */ /* remove form file and isam files */
strxmov(path, mysql_data_home, "/", db, "/", alias, reg_ext, NullS); 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, ...@@ -286,6 +292,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
} }
unlock_table_names(thd, tables); unlock_table_names(thd, tables);
thd->no_warnings_for_error= 0;
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -1955,6 +1962,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -1955,6 +1962,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
const char *operator_name, const char *operator_name,
thr_lock_type lock_type, thr_lock_type lock_type,
bool open_for_modify, bool open_for_modify,
bool no_warnings_for_error,
uint extra_open_options, uint extra_open_options,
int (*prepare_func)(THD *, TABLE_LIST *, int (*prepare_func)(THD *, TABLE_LIST *,
HA_CHECK_OPT *), HA_CHECK_OPT *),
...@@ -1994,7 +2002,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -1994,7 +2002,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
/* open only one table from local list of command */ /* open only one table from local list of command */
next_global_table= table->next_global; next_global_table= table->next_global;
table->next_global= 0; table->next_global= 0;
thd->no_warnings_for_error= no_warnings_for_error;
open_and_lock_tables(thd, table); open_and_lock_tables(thd, table);
thd->no_warnings_for_error= 0;
table->next_global= next_global_table; table->next_global= next_global_table;
/* if view are unsupported */ /* if view are unsupported */
if (table->view && !view_operator_func) if (table->view && !view_operator_func)
...@@ -2218,7 +2228,7 @@ bool mysql_backup_table(THD* thd, TABLE_LIST* table_list) ...@@ -2218,7 +2228,7 @@ bool mysql_backup_table(THD* thd, TABLE_LIST* table_list)
{ {
DBUG_ENTER("mysql_backup_table"); DBUG_ENTER("mysql_backup_table");
DBUG_RETURN(mysql_admin_table(thd, table_list, 0, 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)); &handler::backup, 0));
} }
...@@ -2227,7 +2237,7 @@ bool mysql_restore_table(THD* thd, TABLE_LIST* table_list) ...@@ -2227,7 +2237,7 @@ bool mysql_restore_table(THD* thd, TABLE_LIST* table_list)
{ {
DBUG_ENTER("mysql_restore_table"); DBUG_ENTER("mysql_restore_table");
DBUG_RETURN(mysql_admin_table(thd, table_list, 0, DBUG_RETURN(mysql_admin_table(thd, table_list, 0,
"restore", TL_WRITE, 1, 0, "restore", TL_WRITE, 1, 1, 0,
&prepare_for_restore, &prepare_for_restore,
&handler::restore, 0)); &handler::restore, 0));
} }
...@@ -2237,7 +2247,9 @@ bool mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) ...@@ -2237,7 +2247,9 @@ bool mysql_repair_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
{ {
DBUG_ENTER("mysql_repair_table"); DBUG_ENTER("mysql_repair_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, 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, &prepare_for_repair,
&handler::repair, 0)); &handler::repair, 0));
} }
...@@ -2247,7 +2259,7 @@ bool mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) ...@@ -2247,7 +2259,7 @@ bool mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
{ {
DBUG_ENTER("mysql_optimize_table"); DBUG_ENTER("mysql_optimize_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, 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)); &handler::optimize, 0));
} }
...@@ -2283,7 +2295,7 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, ...@@ -2283,7 +2295,7 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
pthread_mutex_unlock(&LOCK_global_system_variables); pthread_mutex_unlock(&LOCK_global_system_variables);
check_opt.key_cache= key_cache; check_opt.key_cache= key_cache;
DBUG_RETURN(mysql_admin_table(thd, tables, &check_opt, 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)); 0, 0, &handler::assign_to_keycache, 0));
} }
...@@ -2344,7 +2356,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables) ...@@ -2344,7 +2356,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables)
{ {
DBUG_ENTER("mysql_preload_keys"); DBUG_ENTER("mysql_preload_keys");
DBUG_RETURN(mysql_admin_table(thd, tables, 0, 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)); &handler::preload_keys, 0));
} }
...@@ -2510,7 +2522,7 @@ bool mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) ...@@ -2510,7 +2522,7 @@ bool mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
DBUG_ENTER("mysql_analyze_table"); DBUG_ENTER("mysql_analyze_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, 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)); &handler::analyze, 0));
} }
...@@ -2526,7 +2538,7 @@ bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) ...@@ -2526,7 +2538,7 @@ bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
DBUG_ENTER("mysql_check_table"); DBUG_ENTER("mysql_check_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
"check", lock_type, "check", lock_type,
0, HA_OPEN_FOR_REPAIR, 0, 0, HA_OPEN_FOR_REPAIR, 0, 0,
&handler::check, &view_checksum)); &handler::check, &view_checksum));
} }
......
...@@ -49,12 +49,6 @@ bool mysql_union(THD *thd, LEX *lex, select_result *result, ...@@ -49,12 +49,6 @@ bool mysql_union(THD *thd, LEX *lex, select_result *result,
select_union::select_union(TABLE *table_par) select_union::select_union(TABLE *table_par)
: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() select_union::~select_union()
...@@ -71,22 +65,21 @@ int select_union::prepare(List<Item> &list, SELECT_LEX_UNIT *u) ...@@ -71,22 +65,21 @@ int select_union::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
bool select_union::send_data(List<Item> &values) bool select_union::send_data(List<Item> &values)
{ {
int error= 0;
if (unit->offset_limit_cnt) if (unit->offset_limit_cnt)
{ // using limit offset,count { // using limit offset,count
unit->offset_limit_cnt--; unit->offset_limit_cnt--;
return 0; return 0;
} }
fill_record(thd, table->field, values, 1); 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) /* create_myisam_from_heap will generate error if needed */
{ if (error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE &&
thd->clear_error(); // do not report user about table overflow create_myisam_from_heap(thd, table, &tmp_table_param, error, 1))
if (create_myisam_from_heap(thd, table, &tmp_table_param,
info.last_errno, 1))
return 1;
}
else
return 1; return 1;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment