From c9cba59749e1b5a39a9e3a0a5b8bd762507245f9 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Mon, 8 Oct 2018 20:38:58 +0300 Subject: MDEV-17333 Assertion in update_auto_increment() upon exotic LOAD While `handler::next_insert_id` is restored on duplicate key errors `part_share->next_auto_inc_val` is not restored which causes discrepancy. --- sql/handler.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sql/handler.h') diff --git a/sql/handler.h b/sql/handler.h index 8a5c16dc4a7..fcaec4d5030 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3008,6 +3008,10 @@ private: */ Handler_share **ha_share; + /** Stores next_insert_id for handling duplicate key errors. */ + ulonglong m_prev_insert_id; + + public: handler(handlerton *ht_arg, TABLE_SHARE *share_arg) :table_share(share_arg), table(0), @@ -3030,7 +3034,7 @@ public: auto_inc_intervals_count(0), m_psi(NULL), set_top_table_fields(FALSE), top_table(0), top_table_field(0), top_table_fields(0), - m_lock_type(F_UNLCK), ha_share(NULL) + m_lock_type(F_UNLCK), ha_share(NULL), m_prev_insert_id(0) { DBUG_PRINT("info", ("handler created F_UNLCK %d F_RDLCK %d F_WRLCK %d", @@ -3700,6 +3704,16 @@ public: insert_id_for_cur_row; } + /** Store and restore next_insert_id over duplicate key errors. */ + virtual void store_auto_increment() + { + m_prev_insert_id= next_insert_id; + } + virtual void restore_auto_increment() + { + restore_auto_increment(m_prev_insert_id); + } + virtual void update_create_info(HA_CREATE_INFO *create_info) {} int check_old_types(); virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt) -- cgit v1.2.1 From 3c78d1b640f545025235bf52a0bde987817c3685 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Thu, 10 Oct 2019 11:08:31 +0300 Subject: Fix Mroonga compilation Fixed warnings: -Woverloaded-virtual, -Winconsistent-missing-override Caused by c9cba59749e1b5a39a9e3a0a5b8bd762507245f9 --- sql/handler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/handler.h') diff --git a/sql/handler.h b/sql/handler.h index fcaec4d5030..345e0bc1f00 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -3688,7 +3688,7 @@ public: DBUG_PRINT("info",("auto_increment: next value %lu", (ulong)id)); next_insert_id= id; } - void restore_auto_increment(ulonglong prev_insert_id) + virtual void restore_auto_increment(ulonglong prev_insert_id) { /* Insertion of a row failed, re-use the lastly generated auto_increment -- cgit v1.2.1