diff options
author | Marc Alff <marc.alff@sun.com> | 2008-10-06 14:36:15 -0600 |
---|---|---|
committer | Marc Alff <marc.alff@sun.com> | 2008-10-06 14:36:15 -0600 |
commit | ff4fde18c40fa92caabff596100357c2b411116f (patch) | |
tree | 21983f574849b98ac46959575f1a0410aeae950f | |
parent | 1fd6774b3df26a8e2f6b05878d23859796e21c2f (diff) | |
download | mariadb-git-ff4fde18c40fa92caabff596100357c2b411116f.tar.gz |
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.
-rw-r--r-- | mysql-test/r/partition_not_windows.result | 4 | ||||
-rw-r--r-- | mysql-test/r/partition_symlink.result | 4 | ||||
-rw-r--r-- | mysql-test/r/partition_windows.result | 12 | ||||
-rw-r--r-- | mysql-test/r/symlink.result | 10 | ||||
-rw-r--r-- | mysql-test/r/windows.result | 4 | ||||
-rw-r--r-- | sql/mysqld.cc | 22 | ||||
-rw-r--r-- | sql/partition_info.cc | 10 | ||||
-rw-r--r-- | sql/share/errmsg.txt | 12 | ||||
-rw-r--r-- | sql/sql_error.cc | 8 | ||||
-rw-r--r-- | sql/sql_parse.cc | 14 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 8 | ||||
-rw-r--r-- | sql/sql_table.cc | 10 |
12 files changed, 76 insertions, 42 deletions
diff --git a/mysql-test/r/partition_not_windows.result b/mysql-test/r/partition_not_windows.result index 44afdea3855..c0247babb50 100644 --- a/mysql-test/r/partition_not_windows.result +++ b/mysql-test/r/partition_not_windows.result @@ -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 <DATA DIRECTORY> option ignored +Warning 1616 <INDEX DIRECTORY> option ignored show create table t2; Table Create Table t2 CREATE TABLE `t2` ( diff --git a/mysql-test/r/partition_symlink.result b/mysql-test/r/partition_symlink.result index 73844e9e70d..00c9f5b3f01 100644 --- a/mysql-test/r/partition_symlink.result +++ b/mysql-test/r/partition_symlink.result @@ -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 <DATA DIRECTORY> option ignored +Warning 1616 <INDEX DIRECTORY> option ignored show create table t2; Table Create Table t2 CREATE TABLE `t2` ( diff --git a/mysql-test/r/partition_windows.result b/mysql-test/r/partition_windows.result index c2d4054deeb..87e3a3e970d 100644 --- a/mysql-test/r/partition_windows.result +++ b/mysql-test/r/partition_windows.result @@ -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 <DATA DIRECTORY> option ignored +Warning 1616 <INDEX DIRECTORY> option ignored +Warning 1616 <DATA DIRECTORY> option ignored +Warning 1616 <INDEX DIRECTORY> 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 <DATA DIRECTORY> option ignored +Warning 1616 <INDEX DIRECTORY> option ignored INSERT INTO t1 VALUES (NULL, "last", 4); DROP TABLE t1; diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index b8c1660f947..df4aa343f1f 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -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 <DATA DIRECTORY> 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 <DATA DIRECTORY> 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 <INDEX DIRECTORY> 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 'TEST_DIR/master-data_var/t1.MYI' (Errco 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 <DATA DIRECTORY> option ignored +Warning 1616 <INDEX DIRECTORY> option ignored DROP TABLE t1; SET @@SQL_MODE=@OLD_SQL_MODE; End of 5.1 tests diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result index e58a891838a..53c0dd7d767 100644 --- a/mysql-test/r/windows.result +++ b/mysql-test/r/windows.result @@ -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 <DATA DIRECTORY> option ignored +Warning 1616 <INDEX DIRECTORY> option ignored drop table t1; CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (1,1); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b04d4e3cecd..c2d28f9a821 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2800,11 +2800,25 @@ int my_message_sql(uint error, const char *str, myf MyFlags) 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 char *str, myf MyFlags) { 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); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 8feac884c77..bd30d0b5540 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -956,11 +956,13 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, #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()) diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 84eb5f5ba64..1b278523019 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -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" diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 0b74e3455eb..79da1936eb9 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -109,6 +109,9 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, 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_ERROR::enum_warning_level level, 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); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a710b80b4e0..f293a6dc709 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -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)) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 089ef012d3a..13b2bfef24d 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1715,16 +1715,16 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) } 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(); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e317cdab952..243324764f5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -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; |