Commit 5375f0b4 authored by Nayuta Yanagisawa's avatar Nayuta Yanagisawa

MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned...

MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table | Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.

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 INSERT SELECT statements and it results in the
assertion error.
parent f339ef3f
......@@ -860,6 +860,8 @@ SELECT LAST_INSERT_ID();
SELECT * FROM t1;
DROP TABLE t1;
}
--echo ##############################################################################
}
if (!$skip_update)
{
......@@ -867,13 +869,13 @@ if (!$skip_update)
--echo # MDEV-19622 Assertion failures in
--echo # ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
--echo #
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
eval CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=$engine PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
}
if (!$skip_update)
if (!$skip_delete)
{
--echo #
--echo # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
......@@ -884,5 +886,14 @@ REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1;
}
--echo ##############################################################################
if (!$skip_truncate)
{
--echo #
--echo # MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
--echo # Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
--echo #
eval CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE=$engine PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;
}
......@@ -695,3 +695,26 @@ PARTITIONS 2
SELECT * FROM t1 ORDER BY c1;
c1
DROP TABLE t1;
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='Blackhole' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
#
# MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
# ha_partition::set_auto_increment_if_higher
#
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Blackhole' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1;
#
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='Blackhole' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;
......@@ -1101,11 +1101,12 @@ SELECT * FROM t1;
a
0
DROP TABLE t1;
##############################################################################
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='InnoDB' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
......@@ -1116,4 +1117,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='InnoDB' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1;
##############################################################################
#
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='InnoDB' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;
......@@ -1148,11 +1148,12 @@ SELECT * FROM t1;
a
0
DROP TABLE t1;
##############################################################################
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='Aria' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
......@@ -1163,4 +1164,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Aria' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1;
##############################################################################
#
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='Aria' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;
......@@ -1129,11 +1129,12 @@ SELECT * FROM t1;
a
0
DROP TABLE t1;
##############################################################################
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='Memory' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
......@@ -1144,4 +1145,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Memory' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1;
##############################################################################
#
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='Memory' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;
......@@ -1148,11 +1148,12 @@ SELECT * FROM t1;
a
0
DROP TABLE t1;
##############################################################################
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='MyISAM' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
......@@ -1163,4 +1164,11 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='MyISAM' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1;
##############################################################################
#
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='MyISAM' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;
......@@ -1408,7 +1408,8 @@ class ha_partition :public handler
unless we already did it.
*/
if (!part_share->auto_inc_initialized &&
(ha_thd()->lex->sql_command == SQLCOM_INSERT ||
(ha_thd()->lex->sql_command == SQLCOM_INSERT ||
ha_thd()->lex->sql_command == SQLCOM_INSERT_SELECT ||
ha_thd()->lex->sql_command == SQLCOM_REPLACE) &&
table->found_next_number_field)
bitmap_set_all(&m_part_info->read_partitions);
......
......@@ -1115,11 +1115,12 @@ SELECT * FROM t1;
a
0
DROP TABLE t1;
##############################################################################
#
# MDEV-19622 Assertion failures in
# ha_partition::set_auto_increment_if_higher upon UPDATE on Aria table
#
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam PARTITION BY HASH(a);
CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE='TokuDB' PARTITION BY HASH(a);
INSERT INTO t1 VALUES (1,1),(2,2);
UPDATE t1 SET pk = 0;
DROP TABLE t1;
......@@ -1130,5 +1131,12 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='TokuDB' PARTITION BY HASH (a) PARTITIONS 3;
REPLACE INTO t1 PARTITION (p0) VALUES (3);
DROP TABLE t1;
##############################################################################
#
# MDEV-21310 AUTO_INCREMENT column throws range error on INSERT in partitioned table |
# Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed.
#
CREATE TABLE t1 (c INT AUTO_INCREMENT KEY) ENGINE='TokuDB' PARTITION BY LIST (c) (PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
ALTER TABLE t1 TRUNCATE PARTITION p1;
INSERT INTO t1 PARTITION (p1) (c) SELECT 1;
DROP TABLE t1;
SET GLOBAL tokudb_prelock_empty = @tokudb_prelock_empty_saved;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment