diff options
author | TakeKiyo <d8sk4ueum@gmail.com> | 2022-05-18 12:49:24 +0000 |
---|---|---|
committer | Nayuta Yanagisawa <nayuta.yanagisawa@hey.com> | 2022-05-18 23:08:08 +0900 |
commit | 9eb701ccf14e959e400a30e4c89b4c4353519879 (patch) | |
tree | f7a46c3517fc757f3de375552ea399f89078d1a2 | |
parent | c9b5a05341d7342db5f369493ea200b5fb9db243 (diff) | |
download | mariadb-git-bb-10.3-MDEV-14642.tar.gz |
MDEV-14642 Assertion 'table->s->db_create_options == part_table->s->db_create_options' failed in compare_table_with_partitionbb-10.3-MDEV-14642
When trying to execute ALTER TABLE EXCHANGE PARTITION with different definitions, assertion
table->s->db_create_options == part_table->s->db_create_options
failed in compare_table_with_partition().
However, this execution should not be allowed since executing 'exchange partition' requires the identical structure of the two tables.
To fix the problem, I deleted the assertion code and added code that returns an error that indicates tables have different definitions.
-rw-r--r-- | mysql-test/main/partition_exchange.result | 13 | ||||
-rw-r--r-- | mysql-test/main/partition_exchange.test | 18 | ||||
-rw-r--r-- | sql/sql_partition_admin.cc | 9 |
3 files changed, 38 insertions, 2 deletions
diff --git a/mysql-test/main/partition_exchange.result b/mysql-test/main/partition_exchange.result index b27da5b9b8c..ac1b8c99cf7 100644 --- a/mysql-test/main/partition_exchange.result +++ b/mysql-test/main/partition_exchange.result @@ -1308,3 +1308,16 @@ ALTER TABLE t2 REMOVE PARTITIONING; ALTER TABLE t1 EXCHANGE PARTITION pm WITH TABLE t2; ERROR HY000: Non matching attribute 'TABLESPACE' between partition and table DROP TABLE t1, t2; +# +# MDEV-14642 Assertion `table->s->db_create_options == part_table->s->db_create_options' failed in compare_table_with_partition +# +CREATE TABLE t1 (a INT) ROW_FORMAT=DYNAMIC PARTITION BY KEY(a) PARTITIONS 2; +CREATE TABLE t2 (a INT) ; +ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; +ERROR HY000: Tables have different definitions +DROP TABLE t1, t2; +CREATE TABLE t1 (a INT, PRIMARY KEY(a)) ENGINE=InnoDB PARTITION BY KEY(a) PARTITIONS 2; +CREATE TABLE t2 (a INT, PRIMARY KEY(a)) CHECKSUM=1, ENGINE=InnoDB; +ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; +ERROR HY000: Tables have different definitions +DROP TABLE t1, t2; diff --git a/mysql-test/main/partition_exchange.test b/mysql-test/main/partition_exchange.test index cb33b8dd857..a4a89c7b79f 100644 --- a/mysql-test/main/partition_exchange.test +++ b/mysql-test/main/partition_exchange.test @@ -536,3 +536,21 @@ ALTER TABLE t2 REMOVE PARTITIONING; ALTER TABLE t1 EXCHANGE PARTITION pm WITH TABLE t2; DROP TABLE t1, t2; +--echo # +--echo # MDEV-14642 Assertion `table->s->db_create_options == part_table->s->db_create_options' failed in compare_table_with_partition +--echo # +CREATE TABLE t1 (a INT) ROW_FORMAT=DYNAMIC PARTITION BY KEY(a) PARTITIONS 2; +CREATE TABLE t2 (a INT) ; +--error ER_TABLES_DIFFERENT_METADATA +ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; + +# Cleanup +DROP TABLE t1, t2; + +CREATE TABLE t1 (a INT, PRIMARY KEY(a)) ENGINE=InnoDB PARTITION BY KEY(a) PARTITIONS 2; +CREATE TABLE t2 (a INT, PRIMARY KEY(a)) CHECKSUM=1, ENGINE=InnoDB; +--error ER_TABLES_DIFFERENT_METADATA +ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; + +# Cleanup +DROP TABLE t1, t2; diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 90156a76dec..2c3912fc3ee 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -249,8 +249,13 @@ static bool compare_table_with_partition(THD *thd, TABLE *table, my_error(ER_TABLES_DIFFERENT_METADATA, MYF(0)); DBUG_RETURN(TRUE); } - DBUG_ASSERT(table->s->db_create_options == - part_table->s->db_create_options); + + if (table->s->db_create_options != part_table->s->db_create_options) + { + my_error(ER_TABLES_DIFFERENT_METADATA, MYF(0)); + DBUG_RETURN(TRUE); + } + DBUG_ASSERT(table->s->db_options_in_use == part_table->s->db_options_in_use); |