mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-31631 Adding auto-increment to table with history online misbehaves
Adding an auto_increment column online leads to an undefined behavior. Basically any DEFAULTs that depend on a row order in the table, or on the non-deterministic (in scope of the ALTER TABLE statement) function is UB. For example, NOW() is considered generally non-deterministic (Item_func_now_utc is marked with VCOL_NON_DETERMINISTIC), but it's fixed in scope of a single statement. Same for any other function that depends only on the session/status vars apart from its arguments. Only two UB cases are known: * adding new AUTO_INCREMENT column. Modifying the existing column may be fine under certain circumstances, see MDEV-31058. * adding new column with DEFAULT(nextval(...)). Modifying the existing column is possible, since its value will be always present in the online event, except for the NULL -> NOT NULL modification
This commit is contained in:
committed by
Sergei Golubchik
parent
e026a366bf
commit
44ca37ef17
@ -1172,21 +1172,23 @@ set debug_sync= reset;
|
||||
set @old_dbug=@@debug_dbug;
|
||||
set debug_dbug="+d,rpl_report_chosen_key";
|
||||
|
||||
create table t (a int);
|
||||
insert into t values (10),(20),(30);
|
||||
|
||||
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||
--send
|
||||
alter table t add pk int auto_increment primary key, algorithm=copy, lock=none;
|
||||
--connection con2
|
||||
set debug_sync= 'now wait_for downgraded';
|
||||
delete from t where a = 20;
|
||||
update t set a = a + 1 where a = 10;
|
||||
set debug_sync= 'now signal goforit';
|
||||
|
||||
--connection default
|
||||
--reap
|
||||
select * from t;
|
||||
# UB
|
||||
#
|
||||
# create table t (a int);
|
||||
# insert into t values (10),(20),(30);
|
||||
#
|
||||
# set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||
# --send
|
||||
# alter table t add pk int auto_increment primary key, algorithm=copy, lock=none;
|
||||
# --connection con2
|
||||
# set debug_sync= 'now wait_for downgraded';
|
||||
# delete from t where a = 20;
|
||||
# update t set a = a + 1 where a = 10;
|
||||
# set debug_sync= 'now signal goforit';
|
||||
#
|
||||
# --connection default
|
||||
# --reap
|
||||
# select * from t;
|
||||
|
||||
--echo #
|
||||
--echo # Add clumsy DEFAULT
|
||||
|
Reference in New Issue
Block a user