From c758eda7d43d1a83ca975796a8893424104f6443 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 15 Dec 2022 10:42:07 +1100 Subject: MDEV-21007 Do not assert auto_increment_value unless all parts open Commit 6dce6aecebe6ef78a14cb5c5c5daa8a355551e40 breaks out of a loop in ha_partition::info when some partitions aren't opened, in which case auto_increment_value assertion will fail. This commit patches that hole. Signed-off-by: Yuchen Pei Reviewed-by: Alexey Botchkov --- mysql-test/suite/parts/r/mdev_21007.result | 5 +++++ mysql-test/suite/parts/t/mdev_21007.test | 9 +++++++++ sql/ha_partition.cc | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/parts/r/mdev_21007.result create mode 100644 mysql-test/suite/parts/t/mdev_21007.test diff --git a/mysql-test/suite/parts/r/mdev_21007.result b/mysql-test/suite/parts/r/mdev_21007.result new file mode 100644 index 00000000000..fb2417ac3ae --- /dev/null +++ b/mysql-test/suite/parts/r/mdev_21007.result @@ -0,0 +1,5 @@ +CREATE TABLE t1 (a INT) PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (1), PARTITION p1 VALUES LESS THAN (MAXVALUE)); +INSERT INTO t1 VALUES (1),(2); +ALTER TABLE t1 MODIFY a INT AUTO_INCREMENT PRIMARY KEY; +UPDATE t1 PARTITION (p1) SET a=9 ORDER BY a LIMIT 1; +DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/mdev_21007.test b/mysql-test/suite/parts/t/mdev_21007.test new file mode 100644 index 00000000000..ec6fbe4d108 --- /dev/null +++ b/mysql-test/suite/parts/t/mdev_21007.test @@ -0,0 +1,9 @@ +--source include/have_partition.inc + +CREATE TABLE t1 (a INT) PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (1), PARTITION p1 VALUES LESS THAN (MAXVALUE)); +INSERT INTO t1 VALUES (1),(2); +ALTER TABLE t1 MODIFY a INT AUTO_INCREMENT PRIMARY KEY; +UPDATE t1 PARTITION (p1) SET a=9 ORDER BY a LIMIT 1; + +# Cleanup +DROP TABLE t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 06ae329ee3a..4b153ba1135 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -8413,7 +8413,9 @@ int ha_partition::info(uint flag) file->stats.auto_increment_value); } while (*(++file_array)); - DBUG_ASSERT(auto_increment_value); + if (all_parts_opened) { + DBUG_ASSERT(auto_increment_value); + } stats.auto_increment_value= auto_increment_value; if (all_parts_opened && auto_inc_is_first_in_idx) { -- cgit v1.2.1