diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 0da071374ea..ba24f34c383 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -886,4 +886,13 @@ s1 2 3 drop table t1; +create table t1 (a varchar(1)) +partition by key (a) +as select 'a'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(1) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY KEY (a) +drop table t1; End of 5.1 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 272cdc27af6..311289d8fbe 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1009,4 +1009,14 @@ select auto_increment from information_schema.tables where table_name='t1'; select * from t1; drop table t1; +# +# BUG 19062 Partition clause ignored if CREATE TABLE ... AS SELECT ...; +# +create table t1 (a varchar(1)) +partition by key (a) +as select 'a'; + +show create table t1; +drop table t1; + --echo End of 5.1 tests diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b1b498b356d..e75d673d299 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2855,6 +2855,17 @@ mysql_execute_command(THD *thd) res= 1; goto end_with_restore_list; } +#ifdef WITH_PARTITION_STORAGE_ENGINE + { + partition_info *part_info= thd->lex->part_info; + if (part_info && !(part_info= thd->lex->part_info->get_clone())) + { + res= -1; + goto end_with_restore_list; + } + thd->work_part_info= part_info; + } +#endif if (select_lex->item_list.elements) // With select { select_result *result; @@ -2924,15 +2935,6 @@ mysql_execute_command(THD *thd) lex->like_name); else { -#ifdef WITH_PARTITION_STORAGE_ENGINE - partition_info *part_info= thd->lex->part_info; - if (part_info && !(part_info= thd->lex->part_info->get_clone())) - { - res= -1; - goto end_with_restore_list; - } - thd->work_part_info= part_info; -#endif res= mysql_create_table(thd, create_table->db, create_table->table_name, &lex->create_info, lex->create_list,