summaryrefslogtreecommitdiff
path: root/sql/ha_partition.h
diff options
context:
space:
mode:
authorShunsuke Tokunaga <tkngsnsk313320@gmail.com>2022-06-16 13:28:24 +0900
committerGitHub <noreply@github.com>2022-06-16 13:28:24 +0900
commitc4f65d8fed16370deae85115490fc0c06da2ce84 (patch)
treec61e321ea34d38fd875a4c0e4eb5ec5388b9b7c6 /sql/ha_partition.h
parentf31e935c3e0649d36008ab440cd87cb7ff474bb3 (diff)
downloadmariadb-git-c4f65d8fed16370deae85115490fc0c06da2ce84.tar.gz
MDEV-21027 Assertion `part_share->auto_inc_initialized || !can_use_for_auto_inc_init()' failed in ha_partition::set_auto_increment_if_higher
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 says, 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 execute REPLACE on a table that has an AUTO_INCREMENT column. Reviewed by: Nayuta Yanagisawa Reviewed by: Alexey Botchkov
Diffstat (limited to 'sql/ha_partition.h')
-rw-r--r--sql/ha_partition.h7
1 files changed, 4 insertions, 3 deletions
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);
}