diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2021-02-14 23:26:12 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2021-03-31 21:25:36 +0300 |
commit | 0c99e6e9a6a5a64b0d757d796ab53d361e7fb001 (patch) | |
tree | f804f78626e541b8ee21e02203655b2526ae1f3c /sql/handler.cc | |
parent | af52a0e516aa044b7fcdf91b3d2a7036c6c7ae9f (diff) | |
download | mariadb-git-0c99e6e9a6a5a64b0d757d796ab53d361e7fb001.tar.gz |
MDEV-22562 Assertion `next_insert_id == 0' upon UPDATE on system-versioned table
Don't update autoinc counter on history row insert. Uniqueness is kept
due to merge with row_end.
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 79dcee037a5..334ed2d8be2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3326,25 +3326,27 @@ int handler::update_auto_increment() DBUG_RETURN(0); } - // ALTER TABLE ... ADD COLUMN ... AUTO_INCREMENT - if (thd->lex->sql_command == SQLCOM_ALTER_TABLE) + if (table->versioned()) { - if (table->versioned()) + Field *end= table->vers_end_field(); + DBUG_ASSERT(end); + bitmap_set_bit(table->read_set, end->field_index); + if (!end->is_max()) { - Field *end= table->vers_end_field(); - DBUG_ASSERT(end); - bitmap_set_bit(table->read_set, end->field_index); - if (!end->is_max()) + if (thd->lex->sql_command == SQLCOM_ALTER_TABLE) { if (!table->next_number_field->real_maybe_null()) DBUG_RETURN(HA_ERR_UNSUPPORTED); table->next_number_field->set_null(); - DBUG_RETURN(0); } + DBUG_RETURN(0); } - table->next_number_field->set_notnull(); } + // ALTER TABLE ... ADD COLUMN ... AUTO_INCREMENT + if (thd->lex->sql_command == SQLCOM_ALTER_TABLE) + table->next_number_field->set_notnull(); + if ((nr= next_insert_id) >= auto_inc_interval_for_cur_row.maximum()) { /* next_insert_id is beyond what is reserved, so we reserve more. */ |