mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-29069 follow-up: improve DEFAULT rules
previously, fields with DEFAULTs were allowed just when expression is deterministic. In case of online alter, we should recursively check that underlying fields of expression also either have explicit values, or have DEFAULT following this validity rule.
This commit is contained in:
committed by
Sergei Golubchik
parent
30756775d5
commit
41697008fe
@ -1284,6 +1284,42 @@ set debug_sync= 'now signal goforit';
|
||||
--reap
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Useful UNIQUE, though a virtual column on another extra field
|
||||
--echo #
|
||||
create or replace table t (a int primary key, b int default (a+1));
|
||||
insert into t values (10, 10),(20, 20),(30, 30);
|
||||
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||
--send
|
||||
alter table t drop primary key, add c int default(a),
|
||||
add d int as (c) stored unique, algorithm=copy, lock=none;
|
||||
--connection con2
|
||||
set debug_sync= 'now wait_for downgraded';
|
||||
delete from t where a = 20;
|
||||
update t set a = a + 2 where a = 10;
|
||||
set debug_sync= 'now signal goforit';
|
||||
--connection default
|
||||
--reap
|
||||
select * from t;
|
||||
|
||||
--echo #
|
||||
--echo # Now this index is not usable (missing DEFAULT on field c)
|
||||
--echo #
|
||||
create or replace table t (a int primary key, b int);
|
||||
insert into t values (10, 10),(20, 20),(30, 30);
|
||||
set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit';
|
||||
--send
|
||||
alter table t drop primary key, add c real default(rand(a)),
|
||||
add d real as (c) stored unique, algorithm=copy, lock=none;
|
||||
--connection con2
|
||||
set debug_sync= 'now wait_for downgraded';
|
||||
delete from t where a = 20;
|
||||
update t set a = a + 2 where a = 10;
|
||||
set debug_sync= 'now signal goforit';
|
||||
--connection default
|
||||
--reap
|
||||
select a, b from t;
|
||||
|
||||
# Cleanup
|
||||
drop table t;
|
||||
set debug_sync= reset;
|
||||
|
Reference in New Issue
Block a user