From: Date: October 6 2008 10:36pm Subject: bzr commit into mysql-5.1 branch (marc.alff:2762) Bug#36768 List-Archive: http://lists.mysql.com/commits/55489 X-Bug: 36768 Message-Id: <20081006203627.753C52D868@lambda.WEBLAB> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/malff/BZR-TREE/mysql-5.1-36768/ 2762 Marc Alff 2008-10-06 Bug#36768 (partition_info::check_partition_info() reports mal formed warnings) Before this fix, several places in the code would raise a warning with an error code 0, making it impossible for a stored procedure, a connector, or a client application to trigger logic to handle the warning. Also, the warning text was hard coded, and therefore not translated. With this fix, new errors numbers have been created to represent these warnings, and the warning text is coded in the errmsg.txt file. modified: mysql-test/r/partition_not_windows.result mysql-test/r/partition_symlink.result mysql-test/r/partition_windows.result mysql-test/r/symlink.result mysql-test/r/windows.result sql/mysqld.cc sql/partition_info.cc sql/share/errmsg.txt sql/sql_error.cc sql/sql_parse.cc sql/sql_plugin.cc sql/sql_table.cc === modified file 'mysql-test/r/partition_not_windows.result' --- a/mysql-test/r/partition_not_windows.result 2008-03-20 11:22:02 +0000 +++ b/mysql-test/r/partition_not_windows.result 2008-10-06 20:36:15 +0000 @@ -24,8 +24,8 @@ data directory='/not/existing' index directory='/not/existing' ); Warnings: -Warning 0 DATA DIRECTORY option ignored -Warning 0 INDEX DIRECTORY option ignored +Warning 1616 option ignored +Warning 1616 option ignored show create table t2; Table Create Table t2 CREATE TABLE `t2` ( === modified file 'mysql-test/r/partition_symlink.result' --- a/mysql-test/r/partition_symlink.result 2008-08-26 14:31:30 +0000 +++ b/mysql-test/r/partition_symlink.result 2008-10-06 20:36:15 +0000 @@ -101,8 +101,8 @@ data directory='/not/existing' index directory='/not/existing' ); Warnings: -Warning 0 DATA DIRECTORY option ignored -Warning 0 INDEX DIRECTORY option ignored +Warning 1616 option ignored +Warning 1616 option ignored show create table t2; Table Create Table t2 CREATE TABLE `t2` ( === modified file 'mysql-test/r/partition_windows.result' --- a/mysql-test/r/partition_windows.result 2008-01-04 11:06:20 +0000 +++ b/mysql-test/r/partition_windows.result 2008-10-06 20:36:15 +0000 @@ -15,16 +15,16 @@ DATA DIRECTORY = 'E:/mysqltest/p2Data' INDEX DIRECTORY = 'F:/mysqltest/p2Index' ); Warnings: -Warning 0 DATA DIRECTORY option ignored -Warning 0 INDEX DIRECTORY option ignored -Warning 0 DATA DIRECTORY option ignored -Warning 0 INDEX DIRECTORY option ignored +Warning 1616 option ignored +Warning 1616 option ignored +Warning 1616 option ignored +Warning 1616 option ignored INSERT INTO t1 VALUES (NULL, "first", 1); INSERT INTO t1 VALUES (NULL, "second", 2); INSERT INTO t1 VALUES (NULL, "third", 3); ALTER TABLE t1 ADD PARTITION (PARTITION p3 DATA DIRECTORY = 'G:/mysqltest/p3Data' INDEX DIRECTORY = 'H:/mysqltest/p3Index'); Warnings: -Warning 0 DATA DIRECTORY option ignored -Warning 0 INDEX DIRECTORY option ignored +Warning 1616 option ignored +Warning 1616 option ignored INSERT INTO t1 VALUES (NULL, "last", 4); DROP TABLE t1; === modified file 'mysql-test/r/symlink.result' --- a/mysql-test/r/symlink.result 2008-08-26 09:50:32 +0000 +++ b/mysql-test/r/symlink.result 2008-10-06 20:36:15 +0000 @@ -79,7 +79,7 @@ drop database mysqltest; create table t1 (a int not null) engine=myisam; alter table t1 data directory="MYSQLTEST_VARDIR/tmp"; Warnings: -Warning 0 DATA DIRECTORY option ignored +Warning 1616 option ignored show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -88,7 +88,7 @@ t1 CREATE TABLE `t1` ( alter table t1 add b int; alter table t1 data directory="MYSQLTEST_VARDIR/log"; Warnings: -Warning 0 DATA DIRECTORY option ignored +Warning 1616 option ignored show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -97,7 +97,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 alter table t1 index directory="MYSQLTEST_VARDIR/log"; Warnings: -Warning 0 INDEX DIRECTORY option ignored +Warning 1616 option ignored show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -164,8 +164,8 @@ ERROR HY000: Can't create/write to file SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='NO_DIR_IN_CREATE'; CREATE TABLE t1(a INT) DATA DIRECTORY='MYSQLTEST_VARDIR/tmp' INDEX DIRECTORY='MYSQLTEST_VARDIR/tmp'; Warnings: -Warning 0 DATA DIRECTORY option ignored -Warning 0 INDEX DIRECTORY option ignored +Warning 1616 option ignored +Warning 1616 option ignored DROP TABLE t1; SET @@SQL_MODE=@OLD_SQL_MODE; End of 5.1 tests === modified file 'mysql-test/r/windows.result' --- a/mysql-test/r/windows.result 2007-11-18 13:33:12 +0000 +++ b/mysql-test/r/windows.result 2008-10-06 20:36:15 +0000 @@ -9,8 +9,8 @@ drop table nu; drop table if exists t1; CREATE TABLE t1 ( `ID` int(6) ) data directory 'c:/tmp/' index directory 'c:/tmp/' engine=MyISAM; Warnings: -Warning 0 DATA DIRECTORY option ignored -Warning 0 INDEX DIRECTORY option ignored +Warning 1616 option ignored +Warning 1616 option ignored drop table t1; CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (1,1); === modified file 'sql/mysqld.cc' --- a/sql/mysqld.cc 2008-09-29 13:53:40 +0000 +++ b/sql/mysqld.cc 2008-10-06 20:36:15 +0000 @@ -2800,11 +2800,25 @@ int my_message_sql(uint error, const cha THD *thd; DBUG_ENTER("my_message_sql"); DBUG_PRINT("error", ("error: %u message: '%s'", error, str)); + + DBUG_ASSERT(str != NULL); /* - Put here following assertion when situation with EE_* error codes - will be fixed + An error should have a valid error number (!= 0), so it can be caught + in stored procedures by SQL exception handlers. + Calling my_error() with error == 0 is a bug. + Remaining known places to fix: + - storage/myisam/mi_create.c, my_printf_error() + TODO: DBUG_ASSERT(error != 0); */ + + if (error == 0) + { + /* At least, prevent new abuse ... */ + DBUG_ASSERT(strncmp(str, "MyISAM table", 12) == 0); + error= ER_UNKNOWN_ERROR; + } + if ((thd= current_thd)) { /* @@ -2835,10 +2849,6 @@ int my_message_sql(uint error, const cha { if (! thd->main_da.is_error()) // Return only first message { - if (error == 0) - error= ER_UNKNOWN_ERROR; - if (str == NULL) - str= ER(error); thd->main_da.set_error_status(thd, error, str); } query_cache_abort(&thd->net); === modified file 'sql/partition_info.cc' --- a/sql/partition_info.cc 2008-03-20 11:22:02 +0000 +++ b/sql/partition_info.cc 2008-10-06 20:36:15 +0000 @@ -956,11 +956,13 @@ bool partition_info::check_partition_inf #endif { if (part_elem->data_file_name) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "DATA DIRECTORY option ignored"); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), + "DATA DIRECTORY"); if (part_elem->index_file_name) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "INDEX DIRECTORY option ignored"); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED,ER(WARN_OPTION_IGNORED), + "INDEX DIRECTORY"); part_elem->data_file_name= part_elem->index_file_name= NULL; } if (!is_sub_partitioned()) === modified file 'sql/share/errmsg.txt' --- a/sql/share/errmsg.txt 2008-08-06 14:20:41 +0000 +++ b/sql/share/errmsg.txt 2008-10-06 20:36:15 +0000 @@ -6133,3 +6133,15 @@ ER_NEED_REPREPARE ER_DELAYED_NOT_SUPPORTED eng "DELAYED option not supported for table '%-.192s'" + +WARN_NO_MASTER_INFO + eng "The master info structure does not exist" + +WARN_OPTION_IGNORED + eng "<%-.64s> option ignored" + +WARN_PLUGIN_DELETE_BUILTIN + eng "Built-in plugins cannot be deleted" + +WARN_PLUGIN_BUSY + eng "Plugin is busy and will be uninstalled on shutdown" === modified file 'sql/sql_error.cc' --- a/sql/sql_error.cc 2008-02-19 12:58:08 +0000 +++ b/sql/sql_error.cc 2008-10-06 20:36:15 +0000 @@ -109,6 +109,9 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQ DBUG_ENTER("push_warning"); DBUG_PRINT("enter", ("code: %d, msg: %s", code, msg)); + DBUG_ASSERT(code != 0); + DBUG_ASSERT(msg != NULL); + if (level == MYSQL_ERROR::WARN_LEVEL_NOTE && !(thd->options & OPTION_SQL_NOTES)) DBUG_RETURN(0); @@ -177,7 +180,10 @@ void push_warning_printf(THD *thd, MYSQL char warning[ERRMSGSIZE+20]; DBUG_ENTER("push_warning_printf"); DBUG_PRINT("enter",("warning: %u", code)); - + + DBUG_ASSERT(code != 0); + DBUG_ASSERT(format != NULL); + va_start(args,format); my_vsnprintf(warning, sizeof(warning), format, args); va_end(args); === modified file 'sql/sql_parse.cc' --- a/sql/sql_parse.cc 2008-10-02 12:53:08 +0000 +++ b/sql/sql_parse.cc 2008-10-06 20:36:15 +0000 @@ -2324,8 +2324,8 @@ mysql_execute_command(THD *thd) } else { - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "the master info structure does not exist"); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_NO_MASTER_INFO, ER(WARN_NO_MASTER_INFO)); my_ok(thd); } pthread_mutex_unlock(&LOCK_active_mi); @@ -2722,11 +2722,13 @@ end_with_restore_list: /* Don't yet allow changing of symlinks with ALTER TABLE */ if (create_info.data_file_name) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "DATA DIRECTORY option ignored"); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), + "DATA DIRECTORY"); if (create_info.index_file_name) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "INDEX DIRECTORY option ignored"); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), + "INDEX DIRECTORY"); create_info.data_file_name= create_info.index_file_name= NULL; /* ALTER TABLE ends previous transaction */ if (end_active_trans(thd)) === modified file 'sql/sql_plugin.cc' --- a/sql/sql_plugin.cc 2008-08-19 15:35:56 +0000 +++ b/sql/sql_plugin.cc 2008-10-06 20:36:15 +0000 @@ -1715,16 +1715,16 @@ bool mysql_uninstall_plugin(THD *thd, co } if (!plugin->plugin_dl) { - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "Built-in plugins cannot be deleted,."); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_PLUGIN_DELETE_BUILTIN, ER(WARN_PLUGIN_DELETE_BUILTIN)); my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str); goto err; } plugin->state= PLUGIN_IS_DELETED; if (plugin->ref_count) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "Plugin is busy and will be uninstalled on shutdown"); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_PLUGIN_BUSY, ER(WARN_PLUGIN_BUSY)); else reap_needed= true; reap_plugins(); === modified file 'sql/sql_table.cc' --- a/sql/sql_table.cc 2008-09-15 09:19:56 +0000 +++ b/sql/sql_table.cc 2008-10-06 20:36:15 +0000 @@ -3540,11 +3540,13 @@ bool mysql_create_table_no_lock(THD *thd #endif /* HAVE_READLINK */ { if (create_info->data_file_name) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "DATA DIRECTORY option ignored"); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), + "DATA DIRECTORY"); if (create_info->index_file_name) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, - "INDEX DIRECTORY option ignored"); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED), + "INDEX DIRECTORY"); create_info->data_file_name= create_info->index_file_name= 0; } create_info->table_options=db_options;