mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
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.
This commit is contained in:
parent
af52a0e516
commit
0c99e6e9a6
3 changed files with 34 additions and 9 deletions
|
@ -63,3 +63,13 @@ A x y x y
|
|||
1 7 17 7 17
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
#
|
||||
# MDEV-22562 Assertion `next_insert_id == 0' upon UPDATE on system-versioned table
|
||||
#
|
||||
create table t1 (pk integer auto_increment primary key) engine=myisam with system versioning;
|
||||
insert delayed into t1 (pk) values (1);
|
||||
lock tables t1 write;
|
||||
update t1 set pk= 0;
|
||||
update t1 set pk= 0;
|
||||
unlock tables;
|
||||
drop table t1;
|
|
@ -47,4 +47,17 @@ select t1.x = t2.x and t1.y = t2.y as A, t1.x, t1.y, t2.x, t2.y from t1 inner jo
|
|||
drop table t1;
|
||||
drop table t2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-22562 Assertion `next_insert_id == 0' upon UPDATE on system-versioned table
|
||||
--echo #
|
||||
create table t1 (pk integer auto_increment primary key) engine=myisam with system versioning;
|
||||
insert delayed into t1 (pk) values (1);
|
||||
lock tables t1 write;
|
||||
update t1 set pk= 0;
|
||||
update t1 set pk= 0;
|
||||
unlock tables;
|
||||
|
||||
# cleanup
|
||||
drop table t1;
|
||||
|
||||
-- source suite/versioning/common_finish.inc
|
|
@ -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. */
|
||||
|
|
Loading…
Reference in a new issue