1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

test rename alter_table_online -> alter_table_online_debug

This commit is contained in:
Sergei Golubchik
2022-06-29 18:08:50 +02:00
parent 64b55151f4
commit 754333e6ad
2 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,722 @@
--source include/have_debug_sync.inc
--source include/not_embedded.inc
--source include/binlog_combinations.inc
--source include/have_innodb.inc
set default_storage_engine= innodb;
--connect (con2, localhost, root,,)
--connection default
--echo #
--echo # Test insert
--echo #
--echo # Insert and add column
create or replace table t1 (a int);
insert t1 values (5);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add b int NULL, algorithm= copy, lock= none;
--connection con2
--reap
insert into t1 values (123), (456), (789);
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
--echo # Insert, error
create or replace table t1 (a int);
insert t1 values (5), (5);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set session lock_wait_timeout=1;
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add unique (a), algorithm= copy, lock= none;
--connection con2
--reap
start transaction;
insert into t1 values (123), (456), (789);
set debug_sync= 'now SIGNAL end';
--connection default
--error ER_DUP_ENTRY
--reap
--connection con2
commit;
--connection default
select variable_value into @otd from information_schema.session_status where variable_name='Opened_table_definitions';
select * from t1;
select variable_value-@otd from information_schema.session_status where variable_name='Opened_table_definitions';
set session lock_wait_timeout=default;
--echo # long transaction and add column
create or replace table t1 (a int);
insert t1 values (5);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
set session lock_wait_timeout=1;
--send
alter table t1 add b int NULL, algorithm= copy, lock= none;
--connection con2
--reap
start transaction;
insert into t1 values (123), (456), (789);
set debug_sync= 'now SIGNAL end';
--connection default
--error ER_LOCK_WAIT_TIMEOUT
--reap
select * from t1;
set session lock_wait_timeout=default;
--connection con2
rollback;
--connection default
--echo # Insert and add NOT NULL column without default value
create or replace table t1 (a int);
insert t1 values (5);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add b int NOT NULL, algorithm= copy, lock= none;
--connection con2
--reap
insert into t1 values (123), (456), (789);
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
--echo # Insert and add a column with a default value
create or replace table t1 (a int);
insert t1 values (5);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add b int NOT NULL default (222), algorithm= copy, lock= none;
--connection con2
--reap
insert into t1 values (123), (456), (789);
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
--echo #
--echo # Test update
--echo #
--echo # Update and add a column
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 22);
insert t1 values (3, 44);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add c int default(1),
algorithm= copy, lock= none;
--connection con2
--reap
update t1 set b= 55 where a = 1;
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
--echo # Update and add a column in the middle
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 22);
insert t1 values (3, 44);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add c int default(1) after a,
algorithm= copy, lock= none;
--connection con2
--reap
update t1 set b= 55 where a = 1;
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
--echo #
--echo # Test primary key change
--echo #
--echo # Drop key, add key
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 22);
insert t1 values (3, 44);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 drop primary key, add primary key(b),
algorithm= copy, lock= none;
--connection con2
--reap
update t1 set b= 55 where a = 1;
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
--echo # Drop key, add key. Two updates
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 11);
insert t1 values (2, 22);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 drop primary key, add primary key(b),
algorithm= copy, lock= none;
--connection con2
--reap
update t1 set b= 33 where a = 1;
update t1 set b= 44 where a = 2;
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
--echo #
--echo # Various tests, see below
--echo #
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 11);
insert t1 values (2, 22);
insert t1 values (3, 33);
insert t1 values (4, 44);
insert t1 values (5, 55);
insert t1 values (6, 66);
insert t1 values (7, 77);
insert t1 values (8, 88);
insert t1 values (9, 99);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 drop primary key, add primary key(b),
algorithm= copy, lock= none;
--connection con2
--reap
--echo # Two updates
update t1 set b= 1001 where a = 1;
update t1 set b= 2002 where a = 2;
--echo # Two updates in transaction
set autocommit = 0;
start transaction;
update t1 set b= 3003 where a = 3;
update t1 set b= 4004 where a = 4;
commit;
set autocommit = 1;
--echo # Second update is rolled back
update t1 set b= 5005 where a = 5;
set autocommit = 0;
start transaction;
update t1 set b= 6006 where a = 6;
rollback;
set autocommit = 1;
--echo # Second execution in transaction fails
set autocommit = 0;
start transaction;
update t1 set b= 7007 where a = 7;
--error ER_DUP_ENTRY
update t1 set a= 8, b= 8008 where a = 8 or a = 9 order by a;
commit;
set autocommit = 1;
select * from t1;
set debug_sync= 'now SIGNAL end';
--connection default
--reap
--sorted_result
select * from t1;
--echo #
--echo # MYISAM. Only Inserts can be tested.
--echo # (everything else is a table lock disallowing concurrent reads)
--echo #
create or replace table t1 (a int) engine=myisam;
insert t1 values (5);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add b int NULL, algorithm= copy, lock= none;
--connection con2
--reap
insert into t1 values (123), (456), (789);
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
--echo # MYISAM + error
create or replace table t1 (a int primary key) engine=myisam;
insert t1 values (5);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add b int NULL, algorithm= copy, lock= none;
--connection con2
--reap
--error ER_DUP_ENTRY
insert into t1 values (1),(2),(3),(4),(5),(6);
select * from t1;
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
--echo # Aria + error
set @@binlog_format=row; # otherwise aria upgrades the lock to TL_READ_NO_INSERT
create or replace table t1 (a int primary key) engine=aria;
insert t1 values (5);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add b int NULL, algorithm= copy, lock= none;
--connection con2
--reap
--error ER_DUP_ENTRY
insert into t1 values (1),(2),(3),(4),(5),(6);
select * from t1;
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
set @@binlog_format=default;
--echo # Test incompatible changes
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 22);
insert t1 values (3, 44);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 drop primary key, add primary key(b),
algorithm= copy, lock= none;
--connection con2
--reap
update t1 set b= 44 where a = 1;
set debug_sync= 'now SIGNAL end';
--connection default
--error ER_DUP_ENTRY
--reap
select * from t1;
--echo # Test log read after EXCLUSIVE lock
--echo # Transaction is started before ALTER, and UPDATE is made.
--echo # Then more UPDATEs.
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 11);
insert t1 values (2, 22);
insert t1 values (3, 33);
insert t1 values (4, 44);
insert t1 values (5, 55);
set debug_sync= 'alter_table_online_before_lock SIGNAL locking WAIT_FOR end';
set debug_sync= 'alter_table_online_downgraded SIGNAL downgraded';
--send
alter table t1 drop primary key, add primary key(b),
algorithm= copy, lock= none;
--connection con2
begin;
set debug_sync= 'now WAIT_FOR downgraded';
update t1 set b= 111 where a = 1;
set debug_sync= 'now WAIT_FOR locking';
set debug_sync= 'now SIGNAL end';
update t1 set b= 222 where a = 2;
update t1 set b= 333 where a = 3;
update t1 set b= 444 where a = 4;
commit;
update t1 set b= 555 where a = 5;
--connection default
--reap
select * from t1;
--echo #
--echo # Test progress report.
--echo #
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 11);
insert t1 values (2, 22);
insert t1 values (3, 33);
insert t1 values (4, 44);
set debug_sync= 'alter_table_online_before_lock SIGNAL locking WAIT_FOR end';
set debug_sync= 'alter_table_online_downgraded SIGNAL downgraded'
' WAIT_FOR start_replication';
set debug_sync= 'alter_table_online_progress SIGNAL applied WAIT_FOR proceed'
' EXECUTE 9';
--let $con= `select connection_id()`
--send
alter table t1 drop primary key, add primary key(b),
algorithm= copy, lock= none;
--connection con2
set debug_sync= 'now WAIT_FOR downgraded';
update t1 set b= 111 where a = 1;
insert t1 values (5, 55);
update t1 set b= 555 where a = 5;
insert t1 values (6, 66);
update t1 set b= 666 where a = 6;
set debug_sync= 'now SIGNAL start_replication';
--disable_query_log
eval set @con= $con;
--enable_query_log
--echo # First signal is for log description event.
set debug_sync= 'now WAIT_FOR applied';
select stage, progress from INFORMATION_SCHEMA.PROCESSLIST where id = @con;
set debug_sync= 'now SIGNAL proceed WAIT_FOR applied';
select stage, progress from INFORMATION_SCHEMA.PROCESSLIST where id = @con;
set debug_sync= 'now SIGNAL proceed WAIT_FOR applied';
select stage, progress from INFORMATION_SCHEMA.PROCESSLIST where id = @con;
set debug_sync= 'now SIGNAL proceed WAIT_FOR applied';
select stage, progress from INFORMATION_SCHEMA.PROCESSLIST where id = @con;
set debug_sync= 'now SIGNAL proceed WAIT_FOR applied';
select stage, progress from INFORMATION_SCHEMA.PROCESSLIST where id = @con;
set debug_sync= 'now SIGNAL proceed WAIT_FOR applied';
select stage, progress from INFORMATION_SCHEMA.PROCESSLIST where id = @con;
set debug_sync= 'now SIGNAL proceed WAIT_FOR locking';
begin;
update t1 set b= 222 where a = 2;
update t1 set b= 333 where a = 3;
update t1 set b= 444 where a = 4;
commit;
set debug_sync= 'now SIGNAL end WAIT_FOR applied';
select stage, progress from INFORMATION_SCHEMA.PROCESSLIST where id = @con;
set debug_sync= 'now SIGNAL proceed WAIT_FOR applied';
select stage, progress from INFORMATION_SCHEMA.PROCESSLIST where id = @con;
set debug_sync= 'now SIGNAL proceed WAIT_FOR applied';
select stage, progress from INFORMATION_SCHEMA.PROCESSLIST where id = @con;
set debug_sync= 'now SIGNAL proceed';
--connection default
--reap
select * from t1;
--echo #
--echo # Test system versioning
--echo #
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 22);
insert t1 values (3, 44);
--connection con2
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
set timestamp = 1;
--send
alter table t1 add system versioning,
algorithm= copy, lock= none;
--connection con2
--reap
set timestamp = 2;
update t1 set b= 55 where a = 1;
set timestamp = 3;
insert into t1 values (6, 77);
set debug_sync= 'now SIGNAL end';
--connection default
--reap
show create table t1;
select *, UNIX_TIMESTAMP(row_start), UNIX_TIMESTAMP(row_end) from t1 for system_time all;
## at the moment DROP SYSTEM VERSIONING cannot be done online
## because it not only alters the structure, but also deletes history rows
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter table t1 drop system versioning, algorithm= copy, lock= none;
#--connection con2
#--send
#set debug_sync= 'now WAIT_FOR ended';
#
#--connection default
#set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
#
#--send
#alter table t1 drop system versioning,
# algorithm= copy, lock= none;
#
#--connection con2
#--reap
#update t1 set b= 88 where a = 1;
#
#set debug_sync= 'now SIGNAL end';
#
#--connection default
#--reap
#show create table t1;
#select *, UNIX_TIMESTAMP(row_start), UNIX_TIMESTAMP(row_end) from t1 for system_time all;
#
#--connection con2
#--send
#set debug_sync= 'now WAIT_FOR ended';
#
#--connection default
#set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
#
#--send
#alter table t1 drop system versioning,
# algorithm= copy, lock= none;
#
#--connection con2
#--reap
#insert into t1 values (8, 99);
#
#set debug_sync= 'now SIGNAL end';
#
#--connection default
#--reap
#show create table t1;
#select * from t1;
--echo #
--echo # Test ROLLBACK TO SAVEPOINT
--echo #
create or replace table t1 (a int);
insert t1 values (1), (2);
create or replace table t2 (a int);
insert t2 values (1), (2);
--connection con2
begin;
update t2 set a= 222 where a = 2;
savepoint savie;
update t2 set a= 111 where a = 1;
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add b int NULL, algorithm= copy, lock= none;
--connection con2
--reap
update t1 set a= 123 where a = 1;
savepoint whoopsie;
rollback to savepoint savie;
commit;
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
select * from t2;
create or replace table t1 (a int);
insert t1 values (1), (2);
create or replace table t2 (a int);
insert t2 values (1), (2);
create or replace table t3 (a int) engine=myisam;
insert t3 values (1);
--connection con2
begin;
update t2 set a= 222 where a = 2;
savepoint savie;
update t2 set a= 111 where a = 1;
--send
set debug_sync= 'now WAIT_FOR ended';
--connection default
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
--send
alter table t1 add b int NULL, algorithm= copy, lock= none;
--connection con2
--reap
update t1 set a= 222 where a = 2;
savepoint whoopsie;
update t1 set a= 123 where a = 1;
insert t3 values (2);
select * from t1;
rollback to savepoint whoopsie;
select * from t1;
select * from t3;
commit;
set debug_sync= 'now SIGNAL end';
--connection default
--reap
select * from t1;
select * from t2;
select * from t3;
--echo # Cleanup
set debug_sync= 'reset';
drop table t1;
drop table t2;
drop table t3;