Bug #106038 contribution by Tencent : alter innodb partition table crash in debug mode
Submitted: 5 Jan 2022 2:24 Modified: 5 Jan 2022 10:07
Reporter: yuxiang jiang (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Partitions Severity:S6 (Debug Builds)
Version:5.7.36 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[5 Jan 2022 2:24] yuxiang jiang
Description:
DBUG_ASSERT place in wrong place.

In function compare_table_with_partition,  assertion should be done at last.

  DBUG_ASSERT(table->s->db_create_options ==
              part_table->s->db_create_options);
  DBUG_ASSERT(table->s->db_options_in_use ==
              part_table->s->db_options_in_use);

How to repeat:
drop database if exists tcvt1;

create database tcvt1;

use tcvt1;

CREATE TABLE t_10 (a INT,
  b VARCHAR(55),
  PRIMARY KEY (a))
CHECKSUM= 1;

CREATE TABLE tp (a INT,
  b VARCHAR(55),
  PRIMARY KEY (a))
PARTITION BY RANGE (a)
(PARTITION p0 VALUES LESS THAN (10),
 PARTITION p1 VALUES LESS THAN (100),
 PARTITION p2 VALUES LESS THAN (1000));

ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;

Suggested fix:
Move the assertion to the tail of function compare_table_with_partition.
[5 Jan 2022 2:28] yuxiang jiang
contribute from Tencent

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 0001-Fixup-alter-innodb-partition-table-crash-in-debug-mo.patch (application/octet-stream, text), 1.31 KiB.

[5 Jan 2022 6:46] yuxiang jiang
contribution by Tencent
[5 Jan 2022 10:04] MySQL Verification Team
Hello yuxiang jiang,

Thank you for the report and contribution.

regards,
Umesh