diff --git a/mysql-test/main/create_select.result b/mysql-test/main/create_select.result index 15b8eba564b..2fe9bba9872 100644 --- a/mysql-test/main/create_select.result +++ b/mysql-test/main/create_select.result @@ -48,7 +48,7 @@ Warning 1911 Unknown option 'foo' show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `f1` int(11) INVISIBLE DEFAULT NULL, + `f1` int(11) DEFAULT NULL INVISIBLE, `f2` int(11) DEFAULT NULL COMMENT 'a comment', `f3` int(11) DEFAULT NULL `foo`='bar', `f4` int(11) DEFAULT NULL CHECK (`f4` < 10), diff --git a/mysql-test/main/invisible_binlog.result b/mysql-test/main/invisible_binlog.result index 09e4f01f887..9d2d92c10d0 100644 --- a/mysql-test/main/invisible_binlog.result +++ b/mysql-test/main/invisible_binlog.result @@ -40,7 +40,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, - `b` int(11) INVISIBLE DEFAULT NULL + `b` int(11) DEFAULT NULL INVISIBLE ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci select * from t2; a @@ -58,7 +58,7 @@ show create table t2; Table Create Table t2 CREATE TABLE `t2` ( `a` int(11) DEFAULT NULL, - `b` int(11) INVISIBLE DEFAULT 5 + `b` int(11) DEFAULT 5 INVISIBLE ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci connection master; drop table t1,t2; diff --git a/mysql-test/main/invisible_field.result b/mysql-test/main/invisible_field.result index 9d7e9b1a47f..21ab0cc3ed8 100644 --- a/mysql-test/main/invisible_field.result +++ b/mysql-test/main/invisible_field.result @@ -11,7 +11,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `abc` int(11) NOT NULL, - `xyz` int(11) INVISIBLE DEFAULT NULL, + `xyz` int(11) DEFAULT NULL INVISIBLE, PRIMARY KEY (`abc`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci select TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,EXTRA from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA='test' and TABLE_NAME='t1'; @@ -147,7 +147,7 @@ a int(11) YES NULL show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `abc` int(11) NOT NULL INVISIBLE AUTO_INCREMENT, + `abc` int(11) NOT NULL AUTO_INCREMENT INVISIBLE, `a` int(11) DEFAULT NULL, PRIMARY KEY (`abc`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci @@ -419,8 +419,8 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` int(11) NOT NULL, - `b` int(11) INVISIBLE DEFAULT NULL, - `c` int(11) INVISIBLE DEFAULT NULL, + `b` int(11) DEFAULT NULL INVISIBLE, + `c` int(11) DEFAULT NULL INVISIBLE, PRIMARY KEY (`a`), UNIQUE KEY `c` (`c`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result index 4f37594f75e..ad237caea28 100644 --- a/mysql-test/main/mysqldump.result +++ b/mysql-test/main/mysqldump.result @@ -6299,7 +6299,7 @@ insert into t4 values(1); /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, - `b` int(11) INVISIBLE DEFAULT NULL + `b` int(11) DEFAULT NULL INVISIBLE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t1` (`a`, `b`) VALUES (1,NULL), @@ -6318,8 +6318,8 @@ INSERT INTO `t2` VALUES /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t3` ( `invisible` int(11) DEFAULT NULL, - `a b c & $!@#$%^&*( )` int(11) INVISIBLE DEFAULT 4, - `ds=~!@ \# $% ^ & * ( ) _ - = +` int(11) INVISIBLE DEFAULT 5 + `a b c & $!@#$%^&*( )` int(11) DEFAULT 4 INVISIBLE, + `ds=~!@ \# $% ^ & * ( ) _ - = +` int(11) DEFAULT 5 INVISIBLE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t3` (`invisible`, `a b c & $!@#$%^&*( )`, `ds=~!@ \# $% ^ & * ( ) _ - = +`) VALUES (1,4,5), @@ -6340,7 +6340,7 @@ INSERT INTO `t4` VALUES /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( `a` int(11) DEFAULT NULL, - `b` int(11) INVISIBLE DEFAULT NULL + `b` int(11) DEFAULT NULL INVISIBLE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t1` (`a`, `b`) VALUES (1,NULL), @@ -6358,8 +6358,8 @@ INSERT INTO `t2` (`a`, `b`) VALUES (1,2), /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t3` ( `invisible` int(11) DEFAULT NULL, - `a b c & $!@#$%^&*( )` int(11) INVISIBLE DEFAULT 4, - `ds=~!@ \# $% ^ & * ( ) _ - = +` int(11) INVISIBLE DEFAULT 5 + `a b c & $!@#$%^&*( )` int(11) DEFAULT 4 INVISIBLE, + `ds=~!@ \# $% ^ & * ( ) _ - = +` int(11) DEFAULT 5 INVISIBLE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t3` (`invisible`, `a b c & $!@#$%^&*( )`, `ds=~!@ \# $% ^ & * ( ) _ - = +`) VALUES (1,4,5), diff --git a/mysql-test/main/sql_mode.result b/mysql-test/main/sql_mode.result index c5ecae56831..49cac8df414 100644 --- a/mysql-test/main/sql_mode.result +++ b/mysql-test/main/sql_mode.result @@ -148,7 +148,7 @@ f2 timestamp not null default current_timestamp on update current_timestamp); show create table t1; Table Create Table t1 CREATE TABLE "t1" ( - "f1" int(11) NOT NULL AUTO_INCREMENT, + "f1" int(11) NOT NULL, "f2" timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY ("f1") ) diff --git a/mysql-test/suite/federated/federatedx_versioning.result b/mysql-test/suite/federated/federatedx_versioning.result index b561c1fc7a8..d712d19a140 100644 --- a/mysql-test/suite/federated/federatedx_versioning.result +++ b/mysql-test/suite/federated/federatedx_versioning.result @@ -9,8 +9,8 @@ show create table tf; Table Create Table tf CREATE TABLE `tf` ( `x` int(11) DEFAULT NULL, - `row_start` SYS_TYPE INVISIBLE DEFAULT '1971-01-01 00:00:00.000000', - `row_end` SYS_TYPE INVISIBLE DEFAULT '1971-01-01 00:00:00.000000' + `row_start` SYS_TYPE DEFAULT '1971-01-01 00:00:00.000000' INVISIBLE, + `row_end` SYS_TYPE DEFAULT '1971-01-01 00:00:00.000000' INVISIBLE ) ENGINE=FEDERATED DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci CONNECTION='mysql://root@127.0.0.1:MASTER_MYPORT/test/t1' # INSERT insert into t1 values (1); diff --git a/mysql-test/suite/plugins/r/fulltext_plugin.result b/mysql-test/suite/plugins/r/fulltext_plugin.result index 6fcba7735c9..4e9e174c110 100644 --- a/mysql-test/suite/plugins/r/fulltext_plugin.result +++ b/mysql-test/suite/plugins/r/fulltext_plugin.result @@ -14,5 +14,74 @@ Variable_name Value install soname 'mypluglib'; set session_track_system_variables="*"; set session simple_parser_simple_thdvar_one = 10; +set session_track_system_variables=""; uninstall soname 'mypluglib'; # End of 10.5 tests +# +# MDEV-35308 NO_KEY_OPTIONS SQL mode has no effect on engine key options +# +install soname 'mypluglib'; +set sql_mode=ignore_bad_table_options; +create table t1 ( +f1 int foo=bar primary key auto_increment, +f2 int default 3 invisible, +f3 text, +vf1 int as (f2+2) invisible, +unique (f1) koo=12, +fulltext (f3) with parser simple_parser +) too=yes; +Warnings: +Warning 1911 Unknown option 'foo' +Warning 1911 Unknown option 'koo' +Warning 1911 Unknown option 'too' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL AUTO_INCREMENT `foo`=bar, + `f2` int(11) DEFAULT 3 INVISIBLE, + `f3` text DEFAULT NULL, + `vf1` int(11) GENERATED ALWAYS AS (`f2` + 2) VIRTUAL INVISIBLE, + PRIMARY KEY (`f1`), + UNIQUE KEY `f1` (`f1`) `koo`=12, + FULLTEXT KEY `f3` (`f3`) WITH PARSER `simple_parser` +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci `too`=yes +set sql_mode=no_table_options; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL AUTO_INCREMENT /* `foo`=bar */, + `f2` int(11) DEFAULT 3 INVISIBLE, + `f3` text DEFAULT NULL, + `vf1` int(11) GENERATED ALWAYS AS (`f2` + 2) VIRTUAL INVISIBLE, + PRIMARY KEY (`f1`), + UNIQUE KEY `f1` (`f1`) /* `koo`=12 */, + FULLTEXT KEY `f3` (`f3`) WITH PARSER `simple_parser` +) +set sql_mode=no_field_options; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f2` int(11) DEFAULT 3, + `f3` text DEFAULT NULL, + `vf1` int(11) GENERATED ALWAYS AS (`f2` + 2) VIRTUAL, + PRIMARY KEY (`f1`), + UNIQUE KEY `f1` (`f1`) /* `koo`=12 */, + FULLTEXT KEY `f3` (`f3`) WITH PARSER `simple_parser` +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci /* `too`=yes */ +set sql_mode=no_key_options; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL AUTO_INCREMENT /* `foo`=bar */, + `f2` int(11) DEFAULT 3 INVISIBLE, + `f3` text DEFAULT NULL, + `vf1` int(11) GENERATED ALWAYS AS (`f2` + 2) VIRTUAL INVISIBLE, + PRIMARY KEY (`f1`), + UNIQUE KEY `f1` (`f1`), + FULLTEXT KEY `f3` (`f3`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci /* `too`=yes */ +drop table t1; +set sql_mode=default; +uninstall soname 'mypluglib'; +# End of 11.7 tests diff --git a/mysql-test/suite/plugins/t/fulltext_plugin.test b/mysql-test/suite/plugins/t/fulltext_plugin.test index f6f6e169945..7b6f0f4083b 100644 --- a/mysql-test/suite/plugins/t/fulltext_plugin.test +++ b/mysql-test/suite/plugins/t/fulltext_plugin.test @@ -22,6 +22,33 @@ show status like 'a%status'; install soname 'mypluglib'; set session_track_system_variables="*"; set session simple_parser_simple_thdvar_one = 10; +set session_track_system_variables=""; uninstall soname 'mypluglib'; --echo # End of 10.5 tests + +--echo # +--echo # MDEV-35308 NO_KEY_OPTIONS SQL mode has no effect on engine key options +--echo # +install soname 'mypluglib'; +set sql_mode=ignore_bad_table_options; +create table t1 ( + f1 int foo=bar primary key auto_increment, + f2 int default 3 invisible, + f3 text, + vf1 int as (f2+2) invisible, + unique (f1) koo=12, + fulltext (f3) with parser simple_parser +) too=yes; +show create table t1; +set sql_mode=no_table_options; +show create table t1; +set sql_mode=no_field_options; +show create table t1; +set sql_mode=no_key_options; +show create table t1; +drop table t1; +set sql_mode=default; +uninstall soname 'mypluglib'; + +--echo # End of 11.7 tests diff --git a/sql/sql_show.cc b/sql/sql_show.cc index e58acef386f..e46c917eb93 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -152,8 +152,6 @@ static const LEX_CSTRING ha_choice_values[]= { STRING_WITH_LEN("1") } }; -static void store_key_options(THD *, String *, TABLE_SHARE *, KEY *); - static int show_create_view(THD *thd, TABLE_LIST *table, String *buff); static int show_create_sequence(THD *thd, TABLE_LIST *table_list, String *packet); @@ -2186,9 +2184,8 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet, 0 OK */ -int show_create_table_ex(THD *thd, TABLE_LIST *table_list, - const char *force_db, const char *force_name, - String *packet, +int show_create_table_ex(THD *thd, TABLE_LIST *table_list, const char *force_db, + const char *force_name, String *packet, Table_specification_st *create_info_arg, enum_with_db_name with_db_name) { @@ -2348,10 +2345,6 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, packet->append(STRING_WITH_LEN(" STORED")); else packet->append(STRING_WITH_LEN(" VIRTUAL")); - if (field->invisible == INVISIBLE_USER) - { - packet->append(STRING_WITH_LEN(" INVISIBLE")); - } } else { @@ -2374,10 +2367,6 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, packet->append(STRING_WITH_LEN(" NULL")); } - if (field->invisible == INVISIBLE_USER) - { - packet->append(STRING_WITH_LEN(" INVISIBLE")); - } def_value.set(def_value_buf, sizeof(def_value_buf), system_charset_info); if (get_field_default_value(thd, field, &def_value, 1)) { @@ -2396,10 +2385,19 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, packet->append(STRING_WITH_LEN(" ")); packet->append(def_value); } + } - if (field->unireg_check == Field::NEXT_NUMBER && - !(sql_mode & MODE_NO_FIELD_OPTIONS)) + if (!(sql_mode & MODE_NO_FIELD_OPTIONS) && !foreign_db_mode) + { + if (field->unireg_check == Field::NEXT_NUMBER) packet->append(STRING_WITH_LEN(" AUTO_INCREMENT")); + if (!limited_mysql_mode) + { + if (field->invisible == INVISIBLE_USER) + packet->append(STRING_WITH_LEN(" INVISIBLE")); + append_create_options(thd, packet, field->option_list, check_options, + hton->field_options); + } } if (field->comment.length) @@ -2408,9 +2406,6 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, append_unescaped(packet, field->comment.str, field->comment.length); } - append_create_options(thd, packet, field->option_list, check_options, - hton->field_options); - if (field->check_constraint) { StringBuffer str(&my_charset_utf8mb4_general_ci); @@ -2419,7 +2414,6 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, packet->append(str); packet->append(STRING_WITH_LEN(")")); } - } if (period.name) @@ -2503,17 +2497,45 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, } packet->append(')'); - store_key_options(thd, packet, share, &share->key_info[i]); - if (key_info->parser) + + if (!(sql_mode & (MODE_NO_KEY_OPTIONS | MODE_MYSQL323 | MODE_MYSQL40)) && + !foreign_db_mode) { - LEX_CSTRING *parser_name= plugin_name(key_info->parser); - packet->append(STRING_WITH_LEN(" /*!50100 WITH PARSER ")); - append_identifier(thd, packet, parser_name); - packet->append(STRING_WITH_LEN(" */ ")); + if (key_info->algorithm == HA_KEY_ALG_BTREE) + packet->append(STRING_WITH_LEN(" USING BTREE")); + + if (key_info->algorithm == HA_KEY_ALG_HASH || + key_info->algorithm == HA_KEY_ALG_LONG_HASH) + packet->append(STRING_WITH_LEN(" USING HASH")); + + if ((key_info->flags & HA_USES_BLOCK_SIZE) && + share->key_block_size != key_info->block_size) + { + packet->append(STRING_WITH_LEN(" KEY_BLOCK_SIZE=")); + packet->append_ulonglong(key_info->block_size); + } + DBUG_ASSERT(MY_TEST(key_info->flags & HA_USES_COMMENT) == + (key_info->comment.length > 0)); + if (key_info->flags & HA_USES_COMMENT) + { + packet->append(STRING_WITH_LEN(" COMMENT ")); + append_unescaped(packet, key_info->comment.str, + key_info->comment.length); + } + + if (key_info->is_ignored) + packet->append(STRING_WITH_LEN(" IGNORED")); + + if (key_info->parser) + { + LEX_CSTRING *parser_name= plugin_name(key_info->parser); + packet->append(STRING_WITH_LEN(" WITH PARSER ")); + append_identifier(thd, packet, parser_name); + } + append_create_options(thd, packet, key_info->option_list, check_options, + (key_info->algorithm == HA_KEY_ALG_VECTOR + ? mhnsw_index_options : hton->index_options)); } - append_create_options(thd, packet, key_info->option_list, check_options, - (key_info->algorithm == HA_KEY_ALG_VECTOR - ? mhnsw_index_options : hton->index_options)); } if (table->versioned()) @@ -2611,51 +2633,6 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, } -static void store_key_options(THD *thd, String *packet, TABLE_SHARE *share, - KEY *key_info) -{ - bool limited_mysql_mode= (thd->variables.sql_mode & - (MODE_NO_FIELD_OPTIONS | MODE_MYSQL323 | - MODE_MYSQL40)) != 0; - bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL | - MODE_ORACLE | - MODE_MSSQL | - MODE_DB2 | - MODE_MAXDB | - MODE_ANSI)) != 0; - - if (!(thd->variables.sql_mode & MODE_NO_KEY_OPTIONS) && - !limited_mysql_mode && !foreign_db_mode) - { - - if (key_info->algorithm == HA_KEY_ALG_BTREE) - packet->append(STRING_WITH_LEN(" USING BTREE")); - - if (key_info->algorithm == HA_KEY_ALG_HASH || - key_info->algorithm == HA_KEY_ALG_LONG_HASH) - packet->append(STRING_WITH_LEN(" USING HASH")); - - if ((key_info->flags & HA_USES_BLOCK_SIZE) && - share->key_block_size != key_info->block_size) - { - packet->append(STRING_WITH_LEN(" KEY_BLOCK_SIZE=")); - packet->append_ulonglong(key_info->block_size); - } - DBUG_ASSERT(MY_TEST(key_info->flags & HA_USES_COMMENT) == - (key_info->comment.length > 0)); - if (key_info->flags & HA_USES_COMMENT) - { - packet->append(STRING_WITH_LEN(" COMMENT ")); - append_unescaped(packet, key_info->comment.str, - key_info->comment.length); - } - - if (key_info->is_ignored) - packet->append(STRING_WITH_LEN(" IGNORED")); - } -} - - void view_store_options(THD *thd, TABLE_LIST *table, String *buff) { if (table->algorithm != VIEW_ALGORITHM_INHERIT)