Commit 34447eb1 authored by unknown's avatar unknown
Browse files

BUG 19062: CREATE TABLE ... PARTITION BY ... AS SELECT don't create partitioned table


mysql-test/r/partition.result:
  New test case
mysql-test/t/partition.test:
  New test case
sql/sql_parse.cc:
  Moved code to clone the partition info object such that also
  CREATE TABLE ... AS SELECT benefits from it
parent 3065eeb3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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
+10 −0
Original line number Diff line number Diff line
@@ -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
+11 −9
Original line number Diff line number Diff line
@@ -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,