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 /sql | |
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.
Diffstat (limited to 'sql')
-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 |
7 files changed, 59 insertions, 25 deletions
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; |