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.
This commit is contained in:
Marc Alff 2008-10-06 14:36:15 -06:00
parent 1b488e528e
commit e76bb8c665
12 changed files with 76 additions and 42 deletions

View File

@ -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` (

View File

@ -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` (

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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())

View File

@ -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"

View File

@ -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);

View File

@ -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))

View File

@ -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();

View File

@ -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;