Skip to content

Commit 2beede9

Browse files
MDEV-29636 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed in ha_partition::set_auto_increment_if_higher upon REPLACE with partition pruning
The bug is caused by a similar mechanism as MDEV-21027. The function, check_insert_or_replace_autoincrement, failed to open all the partitions on REPLACE SELECT statements and it results in the assertion error.
1 parent a59dffb commit 2beede9

8 files changed

+87
-1
lines changed

mysql-test/suite/parts/inc/partition_auto_increment.inc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,19 @@ eval CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=$
873873
INSERT INTO t1 VALUES (1,1),(2,2);
874874
UPDATE t1 SET pk = 0;
875875
DROP TABLE t1;
876+
877+
--echo #
878+
--echo # MDEV-29636 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
879+
--echo # failed in ha_partition::set_auto_increment_if_higher upon REPLACE
880+
--echo # with partition pruning
881+
--echo #
882+
eval CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE=$engine
883+
PARTITION BY RANGE (a) (
884+
PARTITION p0 VALUES LESS THAN (10),
885+
PARTITION pn VALUES LESS THAN MAXVALUE
886+
);
887+
REPLACE INTO t1 PARTITION (p0) SELECT 1;
888+
DROP TABLE t1;
876889
}
877890

878891
if (!$skip_delete)

mysql-test/suite/parts/r/partition_auto_increment_blackhole.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,18 @@ INSERT INTO t1 VALUES (1,1),(2,2);
704704
UPDATE t1 SET pk = 0;
705705
DROP TABLE t1;
706706
#
707+
# MDEV-29636 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
708+
# failed in ha_partition::set_auto_increment_if_higher upon REPLACE
709+
# with partition pruning
710+
#
711+
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Blackhole'
712+
PARTITION BY RANGE (a) (
713+
PARTITION p0 VALUES LESS THAN (10),
714+
PARTITION pn VALUES LESS THAN MAXVALUE
715+
);
716+
REPLACE INTO t1 PARTITION (p0) SELECT 1;
717+
DROP TABLE t1;
718+
#
707719
# MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
708720
# ha_partition::set_auto_increment_if_higher
709721
#

mysql-test/suite/parts/r/partition_auto_increment_innodb.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,18 @@ INSERT INTO t1 VALUES (1,1),(2,2);
11111111
UPDATE t1 SET pk = 0;
11121112
DROP TABLE t1;
11131113
#
1114+
# MDEV-29636 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
1115+
# failed in ha_partition::set_auto_increment_if_higher upon REPLACE
1116+
# with partition pruning
1117+
#
1118+
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='InnoDB'
1119+
PARTITION BY RANGE (a) (
1120+
PARTITION p0 VALUES LESS THAN (10),
1121+
PARTITION pn VALUES LESS THAN MAXVALUE
1122+
);
1123+
REPLACE INTO t1 PARTITION (p0) SELECT 1;
1124+
DROP TABLE t1;
1125+
#
11141126
# MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
11151127
# ha_partition::set_auto_increment_if_higher
11161128
#

mysql-test/suite/parts/r/partition_auto_increment_maria.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,18 @@ INSERT INTO t1 VALUES (1,1),(2,2);
11581158
UPDATE t1 SET pk = 0;
11591159
DROP TABLE t1;
11601160
#
1161+
# MDEV-29636 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
1162+
# failed in ha_partition::set_auto_increment_if_higher upon REPLACE
1163+
# with partition pruning
1164+
#
1165+
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Aria'
1166+
PARTITION BY RANGE (a) (
1167+
PARTITION p0 VALUES LESS THAN (10),
1168+
PARTITION pn VALUES LESS THAN MAXVALUE
1169+
);
1170+
REPLACE INTO t1 PARTITION (p0) SELECT 1;
1171+
DROP TABLE t1;
1172+
#
11611173
# MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
11621174
# ha_partition::set_auto_increment_if_higher
11631175
#

mysql-test/suite/parts/r/partition_auto_increment_memory.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,18 @@ INSERT INTO t1 VALUES (1,1),(2,2);
11391139
UPDATE t1 SET pk = 0;
11401140
DROP TABLE t1;
11411141
#
1142+
# MDEV-29636 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
1143+
# failed in ha_partition::set_auto_increment_if_higher upon REPLACE
1144+
# with partition pruning
1145+
#
1146+
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Memory'
1147+
PARTITION BY RANGE (a) (
1148+
PARTITION p0 VALUES LESS THAN (10),
1149+
PARTITION pn VALUES LESS THAN MAXVALUE
1150+
);
1151+
REPLACE INTO t1 PARTITION (p0) SELECT 1;
1152+
DROP TABLE t1;
1153+
#
11421154
# MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
11431155
# ha_partition::set_auto_increment_if_higher
11441156
#

mysql-test/suite/parts/r/partition_auto_increment_myisam.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,18 @@ INSERT INTO t1 VALUES (1,1),(2,2);
11581158
UPDATE t1 SET pk = 0;
11591159
DROP TABLE t1;
11601160
#
1161+
# MDEV-29636 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
1162+
# failed in ha_partition::set_auto_increment_if_higher upon REPLACE
1163+
# with partition pruning
1164+
#
1165+
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='MyISAM'
1166+
PARTITION BY RANGE (a) (
1167+
PARTITION p0 VALUES LESS THAN (10),
1168+
PARTITION pn VALUES LESS THAN MAXVALUE
1169+
);
1170+
REPLACE INTO t1 PARTITION (p0) SELECT 1;
1171+
DROP TABLE t1;
1172+
#
11611173
# MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
11621174
# ha_partition::set_auto_increment_if_higher
11631175
#

sql/ha_partition.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,8 @@ class ha_partition :public handler
14101410
if (!part_share->auto_inc_initialized &&
14111411
(ha_thd()->lex->sql_command == SQLCOM_INSERT ||
14121412
ha_thd()->lex->sql_command == SQLCOM_INSERT_SELECT ||
1413-
ha_thd()->lex->sql_command == SQLCOM_REPLACE) &&
1413+
ha_thd()->lex->sql_command == SQLCOM_REPLACE ||
1414+
ha_thd()->lex->sql_command == SQLCOM_REPLACE_SELECT) &&
14141415
table->found_next_number_field)
14151416
bitmap_set_all(&m_part_info->read_partitions);
14161417
}

storage/tokudb/mysql-test/tokudb_parts/r/partition_auto_increment_tokudb.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,18 @@ INSERT INTO t1 VALUES (1,1),(2,2);
11251125
UPDATE t1 SET pk = 0;
11261126
DROP TABLE t1;
11271127
#
1128+
# MDEV-29636 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
1129+
# failed in ha_partition::set_auto_increment_if_higher upon REPLACE
1130+
# with partition pruning
1131+
#
1132+
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='TokuDB'
1133+
PARTITION BY RANGE (a) (
1134+
PARTITION p0 VALUES LESS THAN (10),
1135+
PARTITION pn VALUES LESS THAN MAXVALUE
1136+
);
1137+
REPLACE INTO t1 PARTITION (p0) SELECT 1;
1138+
DROP TABLE t1;
1139+
#
11281140
# MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
11291141
# ha_partition::set_auto_increment_if_higher
11301142
#

0 commit comments

Comments
 (0)