summaryrefslogtreecommitdiff
path: root/mysql-test/main/alter_table_online_debug.test
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2022-11-29 20:40:07 +0100
committerSergei Golubchik <serg@mariadb.org>2022-11-29 20:44:05 +0100
commit5fe6ba34a6e09c887164b436d7226263bc8c41a0 (patch)
tree1594b7ef48b74e8b215679e56325e18320d3b006 /mysql-test/main/alter_table_online_debug.test
parent219aedc134226ecb6024fc8c8b757551d88573b2 (diff)
downloadmariadb-git-bb-10.11-oalter.tar.gz
MDEV-29069 follow-up: improve DEFAULT rulesbb-10.11-oalter
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.
Diffstat (limited to 'mysql-test/main/alter_table_online_debug.test')
-rw-r--r--mysql-test/main/alter_table_online_debug.test36
1 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/main/alter_table_online_debug.test b/mysql-test/main/alter_table_online_debug.test
index 663a5293903..2062f1349b0 100644
--- a/mysql-test/main/alter_table_online_debug.test
+++ b/mysql-test/main/alter_table_online_debug.test
@@ -1270,6 +1270,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;