From 11dbc1c48f6344cda00bae8e939d33f0ff215cd7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 May 2006 17:10:53 -0700 Subject: [PATCH 1/3] Bug#19648 "Merge table does not work with bit types" MERGE should have HA_CAN_BIT_FIELD feature bit set or else table row is formatted incorrectly. mysql-test/r/merge.result: Bug#19648 Test for fix mysql-test/t/merge.test: Bug#19648 Test for fix sql/ha_myisammrg.h: Bug#19648 Must have HA_CAN_BIT_FIELD for BIT type support --- mysql-test/r/merge.result | 6 ++++++ mysql-test/t/merge.test | 9 +++++++++ sql/ha_myisammrg.h | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 9a34d6fba58..568f83b7d6d 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -776,3 +776,9 @@ insert into t1 values ("Monty"),("WAX"),("Walrus"); alter table t1 engine=MERGE; ERROR HY000: Table storage engine for 't1' doesn't have this option drop table t1; +create table t1 (b bit(1)); +create table t2 (b bit(1)); +create table tm (b bit(1)) engine = merge union = (t1,t2); +select * from tm; +b +drop table tm, t1, t2; diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 7ea14a811ed..400279a826b 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -390,4 +390,13 @@ insert into t1 values ("Monty"),("WAX"),("Walrus"); alter table t1 engine=MERGE; drop table t1; +# +# BUG#19648 - Merge table does not work with bit types +# +create table t1 (b bit(1)); +create table t2 (b bit(1)); +create table tm (b bit(1)) engine = merge union = (t1,t2); +select * from tm; +drop table tm, t1, t2; + # End of 5.0 tests diff --git a/sql/ha_myisammrg.h b/sql/ha_myisammrg.h index c762b7c286e..a73f368c51d 100644 --- a/sql/ha_myisammrg.h +++ b/sql/ha_myisammrg.h @@ -37,7 +37,8 @@ class ha_myisammrg: public handler { return (HA_REC_NOT_IN_SEQ | HA_AUTO_PART_KEY | HA_READ_RND_SAME | HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED | - HA_CAN_INSERT_DELAYED | HA_ANY_INDEX_MAY_BE_UNIQUE); + HA_CAN_INSERT_DELAYED | HA_ANY_INDEX_MAY_BE_UNIQUE | + HA_CAN_BIT_FIELD); } ulong index_flags(uint inx, uint part, bool all_parts) const { From cb0f1641fe4f746508e7715fa9417c6afa19e9cc Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jun 2006 22:46:38 -0400 Subject: [PATCH 2/3] BUG#20397: Crash at ALTER TABLE t1 engine = x; for partitioned table mysql-test/r/partition_error.result: New test cases mysql-test/t/partition_error.test: New test cases sql/sql_table.cc: ALTER TABLE t1 engine = x; will behave exactly like ALTER TABLE t1; See no reason why one should change handler to something not specified in query when there is already something one is attached to. --- mysql-test/r/partition_error.result | 24 ++++++++++++++++++++++++ mysql-test/t/partition_error.test | 20 ++++++++++++++++++++ sql/sql_table.cc | 12 ++++++++++++ 3 files changed, 56 insertions(+) diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index a7ca3d9b2fa..a4866209ee6 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -1,4 +1,28 @@ drop table if exists t1; +create table t1 (a int) +engine = x +partition by key (a); +Warnings: +Error 1286 Unknown table engine 'x' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY KEY (a) +drop table t1; +create table t1 (a int) +engine = innodb +partition by list (a) +(partition p0 values in (0)); +alter table t1 engine = x; +Warnings: +Error 1286 Unknown table engine 'x' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY LIST (a) (PARTITION p0 VALUES IN (0) ENGINE = InnoDB) +drop table t1; partition by list (a) partitions 3 (partition x1 values in (1,2,9,4) tablespace ts1, diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 659f0b8cef4..39fde685bce 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -8,6 +8,24 @@ drop table if exists t1; --enable_warnings +# +# Bug 20397: Partitions: Crash when using non-existing engine +# +create table t1 (a int) +engine = x +partition by key (a); +show create table t1; +drop table t1; + +create table t1 (a int) +engine = innodb +partition by list (a) +(partition p0 values in (0)); + +alter table t1 engine = x; +show create table t1; +drop table t1; + # # Partition by key stand-alone error # @@ -775,3 +793,5 @@ partition by range (a + (select count(*) from t1)) -- error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR create table t1 (a char(10)) partition by hash (extractvalue(a,'a')); + + diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a49b7a2cc42..58d50727000 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4992,7 +4992,19 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, old_db_type= table->s->db_type; if (!create_info->db_type) + { + if (create_info->used_fields & HA_CREATE_USED_ENGINE) + { + /* + This case happens when the user specified + ENGINE = x where x is a non-existing storage engine + We clear the flag and treat it the same way + as if no storage engine was specified. + */ + create_info->used_fields^= HA_CREATE_USED_ENGINE; + } create_info->db_type= old_db_type; + } #ifdef WITH_PARTITION_STORAGE_ENGINE if (prep_alter_part_table(thd, table, alter_info, create_info, old_db_type, From 6dd40f3e0ab74846d7793cc32065b4c2aa7741f5 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jun 2006 15:56:47 -0400 Subject: [PATCH 3/3] BUG#20397: Crash when alter table t1 engine = x; Review fixes sql/sql_table.cc: Review fixes --- sql/sql_table.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 58d50727000..7e25c4848ca 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4993,17 +4993,20 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, old_db_type= table->s->db_type; if (!create_info->db_type) { - if (create_info->used_fields & HA_CREATE_USED_ENGINE) + if (table->part_info && + create_info->used_fields & HA_CREATE_USED_ENGINE) { /* This case happens when the user specified ENGINE = x where x is a non-existing storage engine - We clear the flag and treat it the same way - as if no storage engine was specified. + We set create_info->db_type to default_engine_type + to ensure we don't change underlying engine type + due to a erroneously given engine name. */ - create_info->used_fields^= HA_CREATE_USED_ENGINE; + create_info->db_type= table->part_info->default_engine_type; } - create_info->db_type= old_db_type; + else + create_info->db_type= old_db_type; } #ifdef WITH_PARTITION_STORAGE_ENGINE