Skip to content

Commit 8881c01

Browse files
authored
MDEV-14642 Assertion 'table->s->db_create_options == part_table->s->db_create_options' failed in compare_table_with_partition
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. Reviewed By: Nayuta Yanagisawa
1 parent c9b5a05 commit 8881c01

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

mysql-test/main/partition_exchange.result

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,3 +1308,16 @@ ALTER TABLE t2 REMOVE PARTITIONING;
13081308
ALTER TABLE t1 EXCHANGE PARTITION pm WITH TABLE t2;
13091309
ERROR HY000: Non matching attribute 'TABLESPACE' between partition and table
13101310
DROP TABLE t1, t2;
1311+
#
1312+
# MDEV-14642 Assertion `table->s->db_create_options == part_table->s->db_create_options' failed in compare_table_with_partition
1313+
#
1314+
CREATE TABLE t1 (a INT) ROW_FORMAT=DYNAMIC PARTITION BY KEY(a) PARTITIONS 2;
1315+
CREATE TABLE t2 (a INT) ;
1316+
ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
1317+
ERROR HY000: Tables have different definitions
1318+
DROP TABLE t1, t2;
1319+
CREATE TABLE t1 (a INT, PRIMARY KEY(a)) ENGINE=InnoDB PARTITION BY KEY(a) PARTITIONS 2;
1320+
CREATE TABLE t2 (a INT, PRIMARY KEY(a)) CHECKSUM=1, ENGINE=InnoDB;
1321+
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
1322+
ERROR HY000: Tables have different definitions
1323+
DROP TABLE t1, t2;

mysql-test/main/partition_exchange.test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,21 @@ ALTER TABLE t2 REMOVE PARTITIONING;
536536
ALTER TABLE t1 EXCHANGE PARTITION pm WITH TABLE t2;
537537
DROP TABLE t1, t2;
538538

539+
--echo #
540+
--echo # MDEV-14642 Assertion `table->s->db_create_options == part_table->s->db_create_options' failed in compare_table_with_partition
541+
--echo #
542+
CREATE TABLE t1 (a INT) ROW_FORMAT=DYNAMIC PARTITION BY KEY(a) PARTITIONS 2;
543+
CREATE TABLE t2 (a INT) ;
544+
--error ER_TABLES_DIFFERENT_METADATA
545+
ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
546+
547+
# Cleanup
548+
DROP TABLE t1, t2;
549+
550+
CREATE TABLE t1 (a INT, PRIMARY KEY(a)) ENGINE=InnoDB PARTITION BY KEY(a) PARTITIONS 2;
551+
CREATE TABLE t2 (a INT, PRIMARY KEY(a)) CHECKSUM=1, ENGINE=InnoDB;
552+
--error ER_TABLES_DIFFERENT_METADATA
553+
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
554+
555+
# Cleanup
556+
DROP TABLE t1, t2;

sql/sql_partition_admin.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,13 @@ static bool compare_table_with_partition(THD *thd, TABLE *table,
249249
my_error(ER_TABLES_DIFFERENT_METADATA, MYF(0));
250250
DBUG_RETURN(TRUE);
251251
}
252-
DBUG_ASSERT(table->s->db_create_options ==
253-
part_table->s->db_create_options);
252+
253+
if (table->s->db_create_options != part_table->s->db_create_options)
254+
{
255+
my_error(ER_TABLES_DIFFERENT_METADATA, MYF(0));
256+
DBUG_RETURN(TRUE);
257+
}
258+
254259
DBUG_ASSERT(table->s->db_options_in_use ==
255260
part_table->s->db_options_in_use);
256261

0 commit comments

Comments
 (0)