From 9a34f6199b184bf43f67cd7f7ef810ae8dc7df49 Mon Sep 17 00:00:00 2001 From: "mikael@c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se" <> Date: Thu, 15 Jun 2006 14:03:17 -0400 Subject: [PATCH 1/7] BUG#19309: Crash if double procedural alter --- mysql-test/r/partition.result | 8 +++++++ mysql-test/t/partition.test | 14 +++++++++++++ sql/sql_table.cc | 39 +++++++++++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 025d9f46412..d8cb474fefc 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1,5 +1,13 @@ drop table if exists t1; create table t1 (a int) +partition by list (a) +(partition p0 values in (1)); +create procedure pz() +alter table t1 engine = myisam; +call pz(); +call pz(); +drop table t1; +create table t1 (a int) engine = csv partition by list (a) (partition p0 values in (null)); diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index a7f2e1c0b3e..6658064c094 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -9,6 +9,20 @@ drop table if exists t1; --enable_warnings +# +# Bug 19309 Partitions: Crash if double procedural alter +# +create table t1 (a int) +partition by list (a) +(partition p0 values in (1)); + +create procedure pz() +alter table t1 engine = myisam; + +call pz(); +call pz(); +drop table t1; + # # Bug 19307: CSV engine crashes # diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4bc84521f2a..55afd7a5a04 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3001,6 +3001,31 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field) } +/* + Copy HA_CREATE_INFO struct + SYNOPSIS + copy_create_info() + lex_create_info The create_info struct setup by parser + RETURN VALUES + > 0 A pointer to a copy of the lex_create_info + 0 Memory allocation error + DESCRIPTION + Allocate memory for copy of HA_CREATE_INFO structure from parser + to ensure we can reuse the parser struct in stored procedures + and prepared statements. +*/ + +static HA_CREATE_INFO *copy_create_info(HA_CREATE_INFO *lex_create_info) +{ + HA_CREATE_INFO *create_info; + if (!(create_info= (HA_CREATE_INFO*)sql_alloc(sizeof(HA_CREATE_INFO)))) + mem_alloc_error(sizeof(HA_CREATE_INFO)); + else + memcpy((void*)create_info, (void*)lex_create_info, sizeof(HA_CREATE_INFO)); + return create_info; +} + + /* Create a table @@ -3030,7 +3055,7 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field) bool mysql_create_table_internal(THD *thd, const char *db, const char *table_name, - HA_CREATE_INFO *create_info, + HA_CREATE_INFO *lex_create_info, List &fields, List &keys,bool internal_tmp_table, uint select_field_count) @@ -3040,10 +3065,15 @@ bool mysql_create_table_internal(THD *thd, const char *alias; uint db_options, key_count; KEY *key_info_buffer; + HA_CREATE_INFO *create_info; handler *file; bool error= TRUE; DBUG_ENTER("mysql_create_table_internal"); + if (!(create_info= copy_create_info(lex_create_info))) + { + DBUG_RETURN(TRUE); + } /* Check for duplicate fields and check type of table to create */ if (!fields.elements) { @@ -4889,7 +4919,7 @@ static uint compare_tables(TABLE *table, List *create_list, */ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, - HA_CREATE_INFO *create_info, + HA_CREATE_INFO *lex_create_info, TABLE_LIST *table_list, List &fields, List &keys, uint order_num, ORDER *order, @@ -4907,6 +4937,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ulonglong next_insert_id; uint db_create_options, used_fields; handlerton *old_db_type, *new_db_type; + HA_CREATE_INFO *create_info; uint need_copy_table= 0; bool no_table_reopen= FALSE, varchar= FALSE; #ifdef WITH_PARTITION_STORAGE_ENGINE @@ -4932,6 +4963,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, LINT_INIT(index_drop_buffer); thd->proc_info="init"; + if (!(create_info= copy_create_info(lex_create_info))) + { + DBUG_RETURN(TRUE); + } table_name=table_list->table_name; alias= (lower_case_table_names == 2) ? table_list->alias : table_name; db=table_list->db; From 0273a29bf80bff8b7a5d0f44b722da5b04759a5c Mon Sep 17 00:00:00 2001 From: "mikael@c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se" <> Date: Thu, 15 Jun 2006 18:24:33 -0400 Subject: [PATCH 2/7] BUG#19281: Auto-increment disappeared after create index --- mysql-test/r/partition_list.result | 10 ++++++++++ mysql-test/t/partition_list.test | 12 ++++++++++++ sql/ha_partition.cc | 1 + 3 files changed, 23 insertions(+) diff --git a/mysql-test/r/partition_list.result b/mysql-test/r/partition_list.result index 26974e5221d..c722a3c6be3 100644 --- a/mysql-test/r/partition_list.result +++ b/mysql-test/r/partition_list.result @@ -191,3 +191,13 @@ SELECT COUNT(*) FROM t1 WHERE s1 < 3; COUNT(*) 2 DROP TABLE t1; +create table t1 (a int auto_increment primary key) +auto_increment=100 +partition by list (a) +(partition p0 values in (1, 100)); +create index inx on t1 (a); +insert into t1 values (null); +select * from t1; +a +100 +drop table t1; diff --git a/mysql-test/t/partition_list.test b/mysql-test/t/partition_list.test index 3e0eaa45f32..e243ec468e1 100644 --- a/mysql-test/t/partition_list.test +++ b/mysql-test/t/partition_list.test @@ -124,3 +124,15 @@ INSERT INTO t1 VALUES (1), (2), (3), (4), (5); SELECT COUNT(*) FROM t1 WHERE s1 < 3; DROP TABLE t1; +# +# Bug 19281 Partitions: Auto-increment value lost +# +create table t1 (a int auto_increment primary key) +auto_increment=100 +partition by list (a) +(partition p0 values in (1, 100)); +create index inx on t1 (a); +insert into t1 values (null); +select * from t1; +drop table t1; + diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index af0556f1e6f..eab46e96a1a 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1581,6 +1581,7 @@ error: void ha_partition::update_create_info(HA_CREATE_INFO *create_info) { + m_file[0]->update_create_info(create_info); return; } From 805ba2462e680b551f9c644fe267572e95f2d7f0 Mon Sep 17 00:00:00 2001 From: "mikael@dator5.(none)" <> Date: Tue, 20 Jun 2006 10:16:08 -0400 Subject: [PATCH 3/7] Fixed test case --- mysql-test/t/partition_innodb.test | 2 +- mysql-test/t/partition_mgm.test | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index 6a95dd7c8b0..a31d0793565 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -1,5 +1,5 @@ -- source include/have_innodb.inc - +-- source include/have_partition.inc SET @max_row = 20; let $engine= 'InnoDB'; let $MAX_VALUE= (2147483646); diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index 67c0619f28c..afc3b85ea4d 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -1,3 +1,4 @@ +-- source include/have_partition.inc --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings From 32c25c8e2fd131bc350bc44edf7583c67db43ccb Mon Sep 17 00:00:00 2001 From: "mikael@dator5.(none)" <> Date: Tue, 20 Jun 2006 13:24:30 -0400 Subject: [PATCH 4/7] BUG#16000: .par file not removed plus errors to error log for normal errors --- sql/table.cc | 11 +++++++++++ sql/unireg.cc | 1 + 2 files changed, 12 insertions(+) diff --git a/sql/table.cc b/sql/table.cc index ab1bd49ba48..a96ca0da881 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1484,7 +1484,18 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, tmp= fix_partition_func(thd, outparam, is_create_table); *root_ptr= old_root; if (tmp) + { + if (is_create_table) + { + /* + During CREATE/ALTER TABLE it is ok to receive errors here. + It is not ok if it happens during the opening of an frm + file as part of a normal query. + */ + error_reported= TRUE; + } goto err; + } } #endif diff --git a/sql/unireg.cc b/sql/unireg.cc index 11aa73bb502..42518e7b9b7 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -339,6 +339,7 @@ int rea_create_table(THD *thd, const char *path, DBUG_RETURN(0); err_handler: + VOID(file->create_handler_files(path, NULL, CHF_DELETE_FLAG, create_info)); my_delete(frm_name, MYF(0)); DBUG_RETURN(1); } /* rea_create_table */ From a3d5c3bf6d05e6db0a10260cf0dc4c13413fbbe0 Mon Sep 17 00:00:00 2001 From: "mikael@dator5.(none)" <> Date: Tue, 20 Jun 2006 16:38:42 -0400 Subject: [PATCH 5/7] BUG#16000: .par file left behind plus unnecessary messages to error.log New test cases --- mysql-test/r/partition_error.result | 39 +++++++++++++++++++++++++++++ mysql-test/r/partition_mgm.result | 10 ++++++++ mysql-test/t/partition_error.test | 14 +++++++++++ mysql-test/t/partition_mgm.test | 6 +++-- 4 files changed, 67 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index 39f0cf9ca55..f6134c08221 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -89,6 +89,9 @@ partitions 3 partition x2 tablespace ts2, partition x3 tablespace ts3); ERROR HY000: Field in list of fields for partition function not found in table +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -163,6 +166,9 @@ partitions 2 (partition x1 values less than (4), partition x2 values less than (5)); ERROR HY000: Only RANGE PARTITIONING can use VALUES LESS THAN in partition definition +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -173,6 +179,9 @@ partitions 2 (partition x1 values in (4), partition x2 values in (5)); ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -183,6 +192,9 @@ partitions 2 (partition x1 values in (4,6), partition x2 values in (5,7)); ERROR HY000: Only LIST PARTITIONING can use VALUES IN in partition definition +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -191,6 +203,9 @@ primary key (a,b)) partition by key (a) subpartition by key (b); ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -199,6 +214,9 @@ primary key (a,b)) partition by key (a) subpartition by key (a, b); ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -207,6 +225,9 @@ primary key (a,b)) partition by key (a) subpartition by hash (a+b); ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -215,6 +236,9 @@ primary key (a,b)) partition by key (a) subpartition by key (b); ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -223,6 +247,9 @@ primary key (a,b)) partition by key (a) subpartition by key (a, b); ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -231,6 +258,9 @@ primary key (a,b)) partition by key (a) subpartition by hash (a+b); ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -249,6 +279,9 @@ subpartition by hash (sin(a+b)) (partition x1 (subpartition x11, subpartition x12), partition x2 (subpartition x21, subpartition x22)); ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -271,6 +304,9 @@ subpartition by key (a,d) (partition x1 values less than (1) (subpartition x11, subpartition x12), partition x2 values less than (2) (subpartition x21, subpartition x22)); ERROR HY000: Field in list of fields for partition function not found in table +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, @@ -296,6 +332,9 @@ c int not null, primary key(a,b)) partition by range (a); ERROR HY000: For RANGE partitions each partition must be defined +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); +load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par') +NULL CREATE TABLE t1 ( a int not null, b int not null, diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index 48bbdf57b93..5b815f52cbe 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -7,6 +7,12 @@ t1 CREATE TABLE `t1` ( `f_date` date DEFAULT NULL, `f_varchar` varchar(30) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2 +hello/master-data/test/t1#P#p0.MYD +hello/master-data/test/t1#P#p0.MYI +hello/master-data/test/t1#P#p1.MYD +hello/master-data/test/t1#P#p1.MYI +hello/master-data/test/t1.frm +hello/master-data/test/t1.par ALTER TABLE t1 COALESCE PARTITION 1; SHOW CREATE TABLE t1; Table Create Table @@ -14,3 +20,7 @@ t1 CREATE TABLE `t1` ( `f_date` date DEFAULT NULL, `f_varchar` varchar(30) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 1 +hello/master-data/test/t1#P#p0.MYD +hello/master-data/test/t1#P#p0.MYI +hello/master-data/test/t1.frm +hello/master-data/test/t1.par diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 076c5c5773b..d0e3f355292 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -107,6 +107,8 @@ partitions 3 (partition x1 tablespace ts1, partition x2 tablespace ts2, partition x3 tablespace ts3); + +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Partition by hash, invalid field in function # @@ -202,6 +204,7 @@ partition by hash (a) partitions 2 (partition x1 values less than (4), partition x2 values less than (5)); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Partition by hash, values in error @@ -216,6 +219,7 @@ partition by hash (a) partitions 2 (partition x1 values in (4), partition x2 values in (5)); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Partition by hash, values in error @@ -230,6 +234,7 @@ partition by hash (a) partitions 2 (partition x1 values in (4,6), partition x2 values in (5,7)); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Subpartition by key, no partitions defined, single field @@ -242,6 +247,7 @@ c int not null, primary key (a,b)) partition by key (a) subpartition by key (b); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Subpartition by key, no partitions defined, list of fields @@ -254,6 +260,7 @@ c int not null, primary key (a,b)) partition by key (a) subpartition by key (a, b); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Subpartition by hash, no partitions defined @@ -266,6 +273,7 @@ c int not null, primary key (a,b)) partition by key (a) subpartition by hash (a+b); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Subpartition by key, no partitions defined, single field @@ -278,6 +286,7 @@ c int not null, primary key (a,b)) partition by key (a) subpartition by key (b); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Subpartition by key, no partitions defined, list of fields @@ -290,6 +299,7 @@ c int not null, primary key (a,b)) partition by key (a) subpartition by key (a, b); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Subpartition by hash, no partitions defined @@ -302,6 +312,7 @@ c int not null, primary key (a,b)) partition by key (a) subpartition by hash (a+b); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Subpartition by hash, no partitions defined, wrong subpartition function @@ -328,6 +339,7 @@ partition by key (a) subpartition by hash (sin(a+b)) (partition x1 (subpartition x11, subpartition x12), partition x2 (subpartition x21, subpartition x22)); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Subpartition by hash, no partitions defined, wrong subpartition function @@ -356,6 +368,7 @@ partition by range (a) subpartition by key (a,d) (partition x1 values less than (1) (subpartition x11, subpartition x12), partition x2 values less than (2) (subpartition x21, subpartition x22)); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Subpartition by hash, no partitions defined, wrong subpartition function @@ -393,6 +406,7 @@ b int not null, c int not null, primary key(a,b)) partition by range (a); +select load_file('$MYSQLTEST_VARDIR/master-data/test/t1.par'); # # Partition by range, invalid field in function diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index 67c0619f28c..dd9290a97a0 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -5,10 +5,12 @@ CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30)) PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2; SHOW CREATE TABLE t1; -#--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* +--replace_result $MYSQLTEST_VARDIR "hello" +--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* ALTER TABLE t1 COALESCE PARTITION 1; SHOW CREATE TABLE t1; -#--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* +--replace_result $MYSQLTEST_VARDIR "hello" +--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* From de9eb496af2237b86c7ff1ea2b962ae861461e2a Mon Sep 17 00:00:00 2001 From: "mikael@dator5.(none)" <> Date: Wed, 21 Jun 2006 10:57:30 -0400 Subject: [PATCH 6/7] BUG#19309: Problem with calling proecdures twice Need to flag when a copy is needed to not overwrite a create_info object connected to the lex structure --- sql/mysql_priv.h | 3 ++- sql/sql_insert.cc | 2 +- sql/sql_parse.cc | 2 +- sql/sql_table.cc | 35 +++++++++++++++++++++++++++-------- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6f10e812f3e..36d72505076 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -862,7 +862,8 @@ int prepare_create_field(create_field *sql_field, bool mysql_create_table(THD *thd,const char *db, const char *table_name, HA_CREATE_INFO *create_info, List &fields, List &keys, - bool tmp_table, uint select_field_count); + bool tmp_table, uint select_field_count, + bool use_copy_create_info); bool mysql_alter_table(THD *thd, char *new_db, char *new_name, HA_CREATE_INFO *create_info, diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index f1f97400283..8863d138568 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2657,7 +2657,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, tmp_disable_binlog(thd); if (!mysql_create_table(thd, create_table->db, create_table->table_name, create_info, *extra_fields, *keys, 0, - select_field_count)) + select_field_count, 0)) { /* If we are here in prelocked mode we either create temporary table diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 00aacd7b67b..a77f321a437 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2943,7 +2943,7 @@ mysql_execute_command(THD *thd) res= mysql_create_table(thd, create_table->db, create_table->table_name, &lex->create_info, lex->create_list, - lex->key_list, 0, 0); + lex->key_list, 0, 0, 1); } if (!res) send_ok(thd); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a746e91d318..2ecbc94541a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3034,11 +3034,15 @@ static HA_CREATE_INFO *copy_create_info(HA_CREATE_INFO *lex_create_info) thd Thread object db Database table_name Table name - create_info Create information (like MAX_ROWS) + lex_create_info Create information (like MAX_ROWS) fields List of fields to create keys List of keys to create internal_tmp_table Set to 1 if this is an internal temporary table (From ALTER TABLE) + select_field_count + use_copy_create_info Should we make a copy of create info (we do this + when this is called from sql_parse.cc where we + want to ensure lex object isn't manipulated. DESCRIPTION If one creates a temporary table, this is automatically opened @@ -3058,7 +3062,8 @@ bool mysql_create_table_internal(THD *thd, HA_CREATE_INFO *lex_create_info, List &fields, List &keys,bool internal_tmp_table, - uint select_field_count) + uint select_field_count, + bool use_copy_create_info) { char path[FN_REFLEN]; uint path_length; @@ -3070,10 +3075,16 @@ bool mysql_create_table_internal(THD *thd, bool error= TRUE; DBUG_ENTER("mysql_create_table_internal"); - if (!(create_info= copy_create_info(lex_create_info))) + if (use_copy_create_info) { - DBUG_RETURN(TRUE); + if (!(create_info= copy_create_info(lex_create_info))) + { + DBUG_RETURN(TRUE); + } } + else + create_info= lex_create_info; + /* Check for duplicate fields and check type of table to create */ if (!fields.elements) { @@ -3388,7 +3399,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name, HA_CREATE_INFO *create_info, List &fields, List &keys,bool internal_tmp_table, - uint select_field_count) + uint select_field_count, + bool use_copy_create_info) { bool result; DBUG_ENTER("mysql_create_table"); @@ -3412,7 +3424,8 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name, result= mysql_create_table_internal(thd, db, table_name, create_info, fields, keys, internal_tmp_table, - select_field_count); + select_field_count, + use_copy_create_info); pthread_mutex_lock(&LOCK_lock_db); if (!--creating_table && creating_database) @@ -4358,7 +4371,7 @@ bool mysql_preload_keys(THD* thd, TABLE_LIST* tables) */ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, - HA_CREATE_INFO *create_info, + HA_CREATE_INFO *lex_create_info, Table_ident *table_ident) { TABLE *tmp_table; @@ -4371,9 +4384,15 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, int err; bool res= TRUE; enum legacy_db_type not_used; + HA_CREATE_INFO *create_info; TABLE_LIST src_tables_list; DBUG_ENTER("mysql_create_like_table"); + + if (!(create_info= copy_create_info(lex_create_info))) + { + DBUG_RETURN(TRUE); + } src_db= table_ident->db.str ? table_ident->db.str : thd->db; /* @@ -5721,7 +5740,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, */ tmp_disable_binlog(thd); error= mysql_create_table(thd, new_db, tmp_name, - create_info,create_list,key_list,1,0); + create_info,create_list,key_list,1,0,0); reenable_binlog(thd); if (error) DBUG_RETURN(error); From cb5043199bf744be3dbb536c1a67d99bc7a99038 Mon Sep 17 00:00:00 2001 From: "mikael@dator5.(none)" <> Date: Wed, 21 Jun 2006 19:08:30 -0400 Subject: [PATCH 7/7] mmanual merge --- mysql-test/r/partition.result | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 63abaf6eda4..7bea0de80b8 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -6,6 +6,13 @@ create procedure pz() alter table t1 engine = myisam; call pz(); call pz(); +drop procedure pz; +drop table t1; +create table t1 (a int) +engine = csv +partition by list (a) +(partition p0 values in (null)); +ERROR HY000: CSV handler cannot be used in partitioned tables create table t1 (a bigint) partition by range (a) (partition p0 values less than (0xFFFFFFFFFFFFFFFF),