diff options
author | Nayuta Yanagisawa <nayuta.yanagisawa@hey.com> | 2022-09-27 12:01:29 +0900 |
---|---|---|
committer | Nayuta Yanagisawa <nayuta.yanagisawa@hey.com> | 2022-12-07 16:34:56 +0900 |
commit | 2beede9ba48c270d94662f66c49c5129caaa1e8b (patch) | |
tree | 5b2917eb9db0530492627bfc102696976e331dc9 | |
parent | a59dffb0e92704b308476e1e38651318a4c044b2 (diff) | |
download | mariadb-git-2beede9ba48c270d94662f66c49c5129caaa1e8b.tar.gz |
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.
8 files changed, 87 insertions, 1 deletions
diff --git a/mysql-test/suite/parts/inc/partition_auto_increment.inc b/mysql-test/suite/parts/inc/partition_auto_increment.inc index fcfd5bce746..974e4fe559d 100644 --- a/mysql-test/suite/parts/inc/partition_auto_increment.inc +++ b/mysql-test/suite/parts/inc/partition_auto_increment.inc @@ -873,6 +873,19 @@ eval CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=$ INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; + +--echo # +--echo # MDEV-29636 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' +--echo # failed in ha_partition::set_auto_increment_if_higher upon REPLACE +--echo # with partition pruning +--echo # +eval CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE=$engine +PARTITION BY RANGE (a) ( + PARTITION p0 VALUES LESS THAN (10), + PARTITION pn VALUES LESS THAN MAXVALUE +); +REPLACE INTO t1 PARTITION (p0) SELECT 1; +DROP TABLE t1; } if (!$skip_delete) diff --git a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result index 94e4a64ab6a..8c82541b988 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result @@ -704,6 +704,18 @@ INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; # +# 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 +# +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Blackhole' +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (10), +PARTITION pn VALUES LESS THAN MAXVALUE +); +REPLACE INTO t1 PARTITION (p0) SELECT 1; +DROP TABLE t1; +# # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' # ha_partition::set_auto_increment_if_higher # diff --git a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result index a10eee73a2e..48b0d06575a 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result @@ -1111,6 +1111,18 @@ INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; # +# 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 +# +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='InnoDB' +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (10), +PARTITION pn VALUES LESS THAN MAXVALUE +); +REPLACE INTO t1 PARTITION (p0) SELECT 1; +DROP TABLE t1; +# # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' # ha_partition::set_auto_increment_if_higher # diff --git a/mysql-test/suite/parts/r/partition_auto_increment_maria.result b/mysql-test/suite/parts/r/partition_auto_increment_maria.result index d9bc3b77ed5..3767a278503 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_maria.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_maria.result @@ -1158,6 +1158,18 @@ INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; # +# 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 +# +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Aria' +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (10), +PARTITION pn VALUES LESS THAN MAXVALUE +); +REPLACE INTO t1 PARTITION (p0) SELECT 1; +DROP TABLE t1; +# # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' # ha_partition::set_auto_increment_if_higher # diff --git a/mysql-test/suite/parts/r/partition_auto_increment_memory.result b/mysql-test/suite/parts/r/partition_auto_increment_memory.result index c265ffeeed6..936e3e9e1cb 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_memory.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_memory.result @@ -1139,6 +1139,18 @@ INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; # +# 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 +# +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='Memory' +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (10), +PARTITION pn VALUES LESS THAN MAXVALUE +); +REPLACE INTO t1 PARTITION (p0) SELECT 1; +DROP TABLE t1; +# # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' # ha_partition::set_auto_increment_if_higher # diff --git a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result index a0befe8ef2c..475533ceb76 100644 --- a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result +++ b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result @@ -1158,6 +1158,18 @@ INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; # +# 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 +# +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='MyISAM' +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (10), +PARTITION pn VALUES LESS THAN MAXVALUE +); +REPLACE INTO t1 PARTITION (p0) SELECT 1; +DROP TABLE t1; +# # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' # ha_partition::set_auto_increment_if_higher # diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 5d1ca70d3a9..eee73451cdc 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -1410,7 +1410,8 @@ private: if (!part_share->auto_inc_initialized && (ha_thd()->lex->sql_command == SQLCOM_INSERT || ha_thd()->lex->sql_command == SQLCOM_INSERT_SELECT || - ha_thd()->lex->sql_command == SQLCOM_REPLACE) && + ha_thd()->lex->sql_command == SQLCOM_REPLACE || + ha_thd()->lex->sql_command == SQLCOM_REPLACE_SELECT) && table->found_next_number_field) bitmap_set_all(&m_part_info->read_partitions); } diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_auto_increment_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_auto_increment_tokudb.result index b111de8f344..543cc0e1122 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_auto_increment_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_auto_increment_tokudb.result @@ -1125,6 +1125,18 @@ INSERT INTO t1 VALUES (1,1),(2,2); UPDATE t1 SET pk = 0; DROP TABLE t1; # +# 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 +# +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE='TokuDB' +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (10), +PARTITION pn VALUES LESS THAN MAXVALUE +); +REPLACE INTO t1 PARTITION (p0) SELECT 1; +DROP TABLE t1; +# # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' # ha_partition::set_auto_increment_if_higher # |