mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MDEV-5867 ALTER TABLE t1 ENGINE=InnoDB keeps bad options when t1 ENGINE is CONNECT
Comment out unknown options in SHOW CREATE TABLE unless IGNORE_BAD_TABLE_OPTIONS is used
This commit is contained in:
parent
5045615cd9
commit
086a81986b
9 changed files with 142 additions and 7 deletions
37
mysql-test/r/table_options-5867.result
Normal file
37
mysql-test/r/table_options-5867.result
Normal file
|
@ -0,0 +1,37 @@
|
|||
install soname 'ha_example';
|
||||
set sql_mode='ignore_bad_table_options';
|
||||
create table t1 (
|
||||
a int complex='c,f,f,f' invalid=3
|
||||
) engine=example ull=10000 str='dskj' one_or_two='one' yesno=0
|
||||
foobar=barfoo;
|
||||
Warnings:
|
||||
Warning 1911 Unknown option 'invalid'
|
||||
Warning 1911 Unknown option 'foobar'
|
||||
create table t2 (a int, key (a) some_option=2014);
|
||||
Warnings:
|
||||
Warning 1911 Unknown option 'some_option'
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL `complex`='c,f,f,f' `invalid`=3
|
||||
) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ull`=10000 `str`='dskj' `one_or_two`='one' `yesno`=0 `foobar`=barfoo `VAROPT`='5'
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) `some_option`=2014
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
set sql_mode='';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL `complex`='c,f,f,f' /* `invalid`=3 */
|
||||
) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ull`=10000 `str`='dskj' `one_or_two`='one' `yesno`=0 /* `foobar`=barfoo */ `VAROPT`='5'
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
KEY `a` (`a`) /* `some_option`=2014 */
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1, t2;
|
||||
uninstall soname 'ha_example';
|
|
@ -10,6 +10,12 @@ t1 CREATE TABLE `t1` (
|
|||
) ENGINE=EXAMPLE DEFAULT CHARSET=latin1 `ull`=12340 `VAROPT`='5'
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /* `ull`=12340 */
|
||||
set sql_mode=ignore_bad_table_options;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 `ull`=12340
|
||||
|
|
|
@ -23,6 +23,8 @@ show create table t1;
|
|||
sync_slave_with_master;
|
||||
connection slave;
|
||||
show create table t1;
|
||||
set sql_mode=ignore_bad_table_options;
|
||||
show create table t1;
|
||||
|
||||
connection master;
|
||||
drop table t1;
|
||||
|
|
30
mysql-test/t/table_options-5867.test
Normal file
30
mysql-test/t/table_options-5867.test
Normal file
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# MDEV-5867 ALTER TABLE t1 ENGINE=InnoDB keeps bad options when t1 ENGINE is CONNECT
|
||||
#
|
||||
# verify that SHOW CREATE TABLE hides unknown options when IGNORE_BAD_TABLE_OPTIONS is not set
|
||||
|
||||
--source include/have_example_plugin.inc
|
||||
--source include/not_embedded.inc
|
||||
|
||||
install soname 'ha_example';
|
||||
|
||||
set sql_mode='ignore_bad_table_options';
|
||||
create table t1 (
|
||||
a int complex='c,f,f,f' invalid=3
|
||||
) engine=example ull=10000 str='dskj' one_or_two='one' yesno=0
|
||||
foobar=barfoo;
|
||||
|
||||
create table t2 (a int, key (a) some_option=2014);
|
||||
|
||||
show create table t1;
|
||||
show create table t2;
|
||||
|
||||
set sql_mode='';
|
||||
|
||||
show create table t1;
|
||||
show create table t2;
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
uninstall soname 'ha_example';
|
||||
|
|
@ -775,3 +775,20 @@ engine_option_value *merge_engine_table_options(engine_option_value *first,
|
|||
&first, &end);
|
||||
DBUG_RETURN(first);
|
||||
}
|
||||
|
||||
bool is_engine_option_known(engine_option_value *opt,
|
||||
ha_create_table_option *rules)
|
||||
{
|
||||
if (!rules)
|
||||
return false;
|
||||
|
||||
for (; rules->name; rules++)
|
||||
{
|
||||
if (!my_strnncoll(system_charset_info,
|
||||
(uchar*)rules->name, rules->name_length,
|
||||
(uchar*)opt->name.str, opt->name.length))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,4 +99,6 @@ uchar *engine_table_options_frm_image(uchar *buff,
|
|||
|
||||
bool engine_options_differ(void *old_struct, void *new_struct,
|
||||
ha_create_table_option *rules);
|
||||
bool is_engine_option_known(engine_option_value *opt,
|
||||
ha_create_table_option *rules);
|
||||
#endif
|
||||
|
|
|
@ -1519,13 +1519,34 @@ static bool get_field_default_value(THD *thd, Field *field, String *def_value,
|
|||
@param thd thread handler
|
||||
@param packet string to append
|
||||
@param opt list of options
|
||||
@param check_options only print known options
|
||||
@param rules list of known options
|
||||
*/
|
||||
|
||||
static void append_create_options(THD *thd, String *packet,
|
||||
engine_option_value *opt)
|
||||
engine_option_value *opt,
|
||||
bool check_options,
|
||||
ha_create_table_option *rules)
|
||||
{
|
||||
bool in_comment= false;
|
||||
for(; opt; opt= opt->next)
|
||||
{
|
||||
if (check_options)
|
||||
{
|
||||
if (is_engine_option_known(opt, rules))
|
||||
{
|
||||
if (in_comment)
|
||||
packet->append(STRING_WITH_LEN(" */"));
|
||||
in_comment= false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!in_comment)
|
||||
packet->append(STRING_WITH_LEN(" /*"));
|
||||
in_comment= true;
|
||||
}
|
||||
}
|
||||
|
||||
DBUG_ASSERT(opt->value.str);
|
||||
packet->append(' ');
|
||||
append_identifier(thd, packet, opt->name.str, opt->name.length);
|
||||
|
@ -1535,6 +1556,8 @@ static void append_create_options(THD *thd, String *packet,
|
|||
else
|
||||
packet->append(opt->value.str, opt->value.length);
|
||||
}
|
||||
if (in_comment)
|
||||
packet->append(STRING_WITH_LEN(" */"));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1585,6 +1608,8 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
MODE_MYSQL40);
|
||||
bool show_table_options= !(sql_mode & MODE_NO_TABLE_OPTIONS) &&
|
||||
!foreign_db_mode;
|
||||
bool check_options= !(sql_mode & MODE_IGNORE_BAD_TABLE_OPTIONS) &&
|
||||
!create_info_arg;
|
||||
handlerton *hton;
|
||||
my_bitmap_map *old_map;
|
||||
int error= 0;
|
||||
|
@ -1734,7 +1759,8 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
packet->append(STRING_WITH_LEN(" COMMENT "));
|
||||
append_unescaped(packet, field->comment.str, field->comment.length);
|
||||
}
|
||||
append_create_options(thd, packet, field->option_list);
|
||||
append_create_options(thd, packet, field->option_list, check_options,
|
||||
hton->field_options);
|
||||
}
|
||||
|
||||
key_info= table->key_info;
|
||||
|
@ -1801,7 +1827,8 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
append_identifier(thd, packet, parser_name->str, parser_name->length);
|
||||
packet->append(STRING_WITH_LEN(" */ "));
|
||||
}
|
||||
append_create_options(thd, packet, key_info->option_list);
|
||||
append_create_options(thd, packet, key_info->option_list, check_options,
|
||||
hton->index_options);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1952,7 +1979,8 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
|
|||
packet->append(STRING_WITH_LEN(" CONNECTION="));
|
||||
append_unescaped(packet, share->connect_string.str, share->connect_string.length);
|
||||
}
|
||||
append_create_options(thd, packet, share->option_list);
|
||||
append_create_options(thd, packet, share->option_list, check_options,
|
||||
hton->table_options);
|
||||
append_directory(thd, packet, "DATA", create_info.data_file_name);
|
||||
append_directory(thd, packet, "INDEX", create_info.index_file_name);
|
||||
}
|
||||
|
@ -5129,7 +5157,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
|
|||
str.qs_append(STRING_WITH_LEN(" transactional="));
|
||||
str.qs_append(ha_choice_values[(uint) share->transactional]);
|
||||
}
|
||||
append_create_options(thd, &str, share->option_list);
|
||||
append_create_options(thd, &str, share->option_list, false, 0);
|
||||
|
||||
if (str.length())
|
||||
table->field[19]->store(str.ptr()+1, str.length()-1, cs);
|
||||
|
|
|
@ -218,13 +218,22 @@ Three 3
|
|||
# Changing to another engine is Ok
|
||||
# However, the data file is not deleted.
|
||||
#
|
||||
ALTER TABLE t1 ENGINE=MARIA;
|
||||
ALTER TABLE t1 ENGINE=ARIA;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`d` char(10) NOT NULL /* `FLAG`=11 */,
|
||||
`c` int(11) NOT NULL /* `FLAG`=0 */
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 /* `TABLE_TYPE`=fix `FILE_NAME`='tf1.txt' `ENDING`=1 */
|
||||
set @old_sql_mode=@@sql_mode;
|
||||
set sql_mode=ignore_bad_table_options;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`d` char(10) NOT NULL `FLAG`=11,
|
||||
`c` int(11) NOT NULL `FLAG`=0
|
||||
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 `TABLE_TYPE`=fix `FILE_NAME`='tf1.txt' `ENDING`=1
|
||||
set sql_mode=@old_sql_mode;
|
||||
SELECT * from t1;
|
||||
d c
|
||||
One 1
|
||||
|
|
|
@ -105,8 +105,12 @@ SELECT * FROM t1;
|
|||
--echo # Changing to another engine is Ok
|
||||
--echo # However, the data file is not deleted.
|
||||
--echo #
|
||||
ALTER TABLE t1 ENGINE=MARIA;
|
||||
ALTER TABLE t1 ENGINE=ARIA;
|
||||
SHOW CREATE TABLE t1;
|
||||
set @old_sql_mode=@@sql_mode;
|
||||
set sql_mode=ignore_bad_table_options;
|
||||
SHOW CREATE TABLE t1;
|
||||
set sql_mode=@old_sql_mode;
|
||||
SELECT * from t1;
|
||||
SELECT * from t2;
|
||||
|
||||
|
|
Loading…
Reference in a new issue