summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShunpoco <tkngsnsk313320@gmail.com>2022-05-20 12:23:20 +0900
committerNayuta Yanagisawa <nayuta.yanagisawa@hey.com>2022-06-16 00:30:30 +0900
commita872145bb1a6eea6ba982d8774642ef284709bde (patch)
tree4e344f6bc335c2810d77eb1db401a25d549c4f5e
parente077ce2a68a418d0f4cbe32f9311cf235ee1578c (diff)
downloadmariadb-git-bb-10.3-MDEV-21027.tar.gz
MDEV-21027: Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed in ha_partition::set_auto_increment_if_higherbb-10.3-MDEV-21027
ha_partition::set_auto_increment_if_higher expects part_share->auto_inc_initialized is true or can_use_for_auto_inc_init() is false (but as the comment of this method saids, it returns false only if we use Spider engine with DROP TABLE or ALTER TABLE query). However, part_share->auto_inc_initialized becomes true only after all partitions are opened (since 6dce6aecebe6ef78a14cb5c5c5daa8a355551e40). Therefore, I added a conditional expression in order to read all partitions when we REPLACE a table that has an AUTO_INCREMENT column.
-rw-r--r--mysql-test/suite/parts/inc/partition_auto_increment.inc11
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_innodb.result7
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_maria.result7
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_memory.result7
-rw-r--r--mysql-test/suite/parts/r/partition_auto_increment_myisam.result7
-rw-r--r--sql/ha_partition.cc4
-rw-r--r--sql/ha_partition.h7
-rw-r--r--storage/tokudb/mysql-test/tokudb_parts/r/partition_auto_increment_tokudb.result7
8 files changed, 52 insertions, 5 deletions
diff --git a/mysql-test/suite/parts/inc/partition_auto_increment.inc b/mysql-test/suite/parts/inc/partition_auto_increment.inc
index 4392d04db8a..2997dd9de4f 100644
--- a/mysql-test/suite/parts/inc/partition_auto_increment.inc
+++ b/mysql-test/suite/parts/inc/partition_auto_increment.inc
@@ -873,5 +873,16 @@ UPDATE t1 SET pk = 0;
DROP TABLE t1;
}
+if (!$skip_update)
+{
+--echo #
+--echo # MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()'
+--echo # ha_partition::set_auto_increment_if_higher
+--echo #
+eval CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) ENGINE=$engine PARTITION BY HASH (a) PARTITIONS 3;
+REPLACE INTO t1 PARTITION (p0) VALUES (3);
+DROP TABLE t1;
+}
+
--echo ##############################################################################
}
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 76f1ddfceae..e5414c81616 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result
@@ -1109,4 +1109,11 @@ CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam
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='InnoDB' PARTITION BY HASH (a) PARTITIONS 3;
+REPLACE INTO t1 PARTITION (p0) VALUES (3);
+DROP TABLE t1;
##############################################################################
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 5a3902475a9..ad041735ebb 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_maria.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_maria.result
@@ -1156,4 +1156,11 @@ CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam
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='Aria' PARTITION BY HASH (a) PARTITIONS 3;
+REPLACE INTO t1 PARTITION (p0) VALUES (3);
+DROP TABLE t1;
##############################################################################
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 c395f8ed0c9..d2d1fb6831c 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_memory.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_memory.result
@@ -1137,4 +1137,11 @@ CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam
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='Memory' PARTITION BY HASH (a) PARTITIONS 3;
+REPLACE INTO t1 PARTITION (p0) VALUES (3);
+DROP TABLE t1;
##############################################################################
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 792423096b5..f92a6ed18c6 100644
--- a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result
+++ b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result
@@ -1156,4 +1156,11 @@ CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam
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='MyISAM' PARTITION BY HASH (a) PARTITIONS 3;
+REPLACE INTO t1 PARTITION (p0) VALUES (3);
+DROP TABLE t1;
##############################################################################
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 48c479070a5..5c08c934dde 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -3661,7 +3661,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
}
else
{
- check_insert_autoincrement();
+ check_insert_or_replace_autoincrement();
if (unlikely((error= open_read_partitions(name_buff, sizeof(name_buff)))))
goto err_handler;
m_num_locks= m_file_sample->lock_count();
@@ -8666,7 +8666,7 @@ int ha_partition::change_partitions_to_open(List<String> *partition_names)
return 0;
}
- check_insert_autoincrement();
+ check_insert_or_replace_autoincrement();
if (bitmap_cmp(&m_opened_partitions, &m_part_info->read_partitions) != 0)
return 0;
diff --git a/sql/ha_partition.h b/sql/ha_partition.h
index e85c61b839d..6c0e4ef6cf2 100644
--- a/sql/ha_partition.h
+++ b/sql/ha_partition.h
@@ -1400,15 +1400,16 @@ private:
unlock_auto_increment();
}
- void check_insert_autoincrement()
+ void check_insert_or_replace_autoincrement()
{
/*
- If we INSERT into the table having the AUTO_INCREMENT column,
+ If we INSERT or REPLACE into the table having the AUTO_INCREMENT column,
we have to read all partitions for the next autoincrement value
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_REPLACE) &&
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 14b6052a7d3..9b79cc21875 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
@@ -1123,5 +1123,12 @@ CREATE OR REPLACE TABLE t1 (pk INT AUTO_INCREMENT, a INT, KEY(pk)) ENGINE=myisam
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='TokuDB' PARTITION BY HASH (a) PARTITIONS 3;
+REPLACE INTO t1 PARTITION (p0) VALUES (3);
+DROP TABLE t1;
##############################################################################
SET GLOBAL tokudb_prelock_empty = @tokudb_prelock_empty_saved;