polardbxengine/mysql-test/suite/xengine/t/online_ddl_concurrent_dml.test

326 lines
11 KiB
Plaintext

--source suite/xengine/include/have_xengine.inc
--source include/have_debug.inc
###################################################################
# test the online DML&DML
###################################################################
--disable_warnings
drop table if exists t1;
--enable_warnings
CREATE TABLE t1 (id INT primary key, c1 INT, c2 int, c3 int) ENGINE=xengine;
insert into t1 values(1,1,1,1),(5,5,5,5),(9,9,9,9);
# set the wait point to insert key2
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml_insert WAIT_FOR start_dml_insert_finish';
send alter table t1 drop column c1, add column c4 int default 100 ,ALGORITHM = INPLACE, LOCK=DEFAULT;
--echo # Establish connection con1 (user=root)
connect (con1,localhost,root,,);
--echo # Switch to connection con1
connection con1;
# insert key2
# wait the create sk ddl enter the inplace_create_sk_scan_base_begin point
SET DEBUG_SYNC= 'now WAIT_FOR start_dml_insert';
insert into t1 values(6,6,6,6),(7,7,7,7);
select * from t1;
update t1 set c2=100 where id > 6;
select * from t1;
update t1 set c1=99 where id > 6;
select * from t1;
delete from t1 where id=1;
select * from t1;
# signal create sk ddl the key2 has been inserted
SET DEBUG_SYNC= 'now SIGNAL start_dml_insert_finish';
--echo # Switch to connection default
connection default;
# receive the result of alter table, expected create index fail
reap;
show create table t1;
select * from t1;
drop table t1;
#################################################
###test varchar mixed int with multi-keys
#################################################
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(id int primary key, c1 int, c2 varchar(100), c3 int) engine=xengine;
insert into t1 values(1,11,'abc',111);
insert into t1 values(2,12,'abc',222);
insert into t1 values(3,13,'abc',333);
alter table t1 add index idx_c1(c1),algorithm=inplace,lock=default;
alter table t1 add index idx_c2(c2),algorithm=inplace,lock=default;
alter table t1 add index idx_c3(c3),algorithm=inplace,lock=default;
alter table t1 add index idx_c1_c2(c1,c2),algorithm=inplace,lock=default;
# set the wait point to insert key2
connection default;
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml_insert WAIT_FOR start_dml_insert_finish';
send alter table t1 drop column c1, add column c4 int default 100 ,ALGORITHM = INPLACE, LOCK=DEFAULT;
--echo # Switch to connection con1
connection con1;
# insert key2
# wait the create sk ddl enter the inplace_create_sk_scan_base_begin point
SET DEBUG_SYNC= 'now WAIT_FOR start_dml_insert';
insert into t1 values(6,6,'6666',6),(7,7,'777777',7);
select * from t1;
update t1 set c2='aaaa' where id > 6;
select * from t1;
update t1 set c1=99 where id > 6;
select * from t1;
delete from t1 where id=1;
select * from t1;
# signal create sk ddl the key2 has been inserted
SET DEBUG_SYNC= 'now SIGNAL start_dml_insert_finish';
--echo # Switch to connection default
connection default;
# receive the result of alter table, expected create index fail
reap;
show create table t1;
select * from t1;
drop table t1;
##################################################################
###test new add columns, and new column is part of new indexes
#################################################################
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(id int primary key, c1 int, c2 varchar(100), c3 int) engine=xengine;
insert into t1 values(1,11,'abc',111);
insert into t1 values(2,12,'abc',222);
insert into t1 values(3,13,'abc',333);
# set the wait point to insert key2
connection default;
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml_insert WAIT_FOR start_dml_insert_finish';
send alter table t1 add column c4 int default 100, add index idx_c4(c4) ,ALGORITHM = INPLACE, LOCK=DEFAULT;
--echo # Switch to connection con1
connection con1;
# insert key2
# wait the create sk ddl enter the inplace_create_sk_scan_base_begin point
SET DEBUG_SYNC= 'now WAIT_FOR start_dml_insert';
insert into t1 values(6,6,'6666',6),(7,7,'777777',7);
select * from t1;
update t1 set c2='aaaa' where id > 6;
select * from t1;
update t1 set c1=99 where id > 6;
select * from t1;
delete from t1 where id=1;
select * from t1;
# signal create sk ddl the key2 has been inserted
SET DEBUG_SYNC= 'now SIGNAL start_dml_insert_finish';
--echo # Switch to connection default
connection default;
# receive the result of alter table, expected create index fail
reap;
check table t1;
select * from t1;
show create table t1;
drop table t1;
##################################################################
###test modify pk
#################################################################
--echo "test modify pk"
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(id int not null primary key, c1 int not null, c2 varchar(100), c3 int) engine=xengine;
insert into t1 values(1,11,'abc',111);
insert into t1 values(2,12,'abc',222);
insert into t1 values(3,13,'abc',333);
# set the wait point to insert key2
connection default;
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml_insert WAIT_FOR start_dml_insert_finish';
send alter table t1 drop primary key, add primary key(c1), ALGORITHM = INPLACE, LOCK=DEFAULT;
--echo # Switch to connection con1
connection con1;
# insert key2
# wait the create sk ddl enter the inplace_create_sk_scan_base_begin point
SET DEBUG_SYNC= 'now WAIT_FOR start_dml_insert';
insert into t1 values(6,6,'6666',6),(7,7,'777777',7);
select * from t1;
update t1 set c2='aaaa' where id > 6;
select * from t1;
update t1 set c1=99 where id > 6;
select * from t1;
delete from t1 where id=1;
select * from t1;
# signal create sk ddl the key2 has been inserted
SET DEBUG_SYNC= 'now SIGNAL start_dml_insert_finish';
--echo # Switch to connection default
connection default;
# receive the result of alter table, expected create index fail
reap;
check table t1;
select * from t1;
show create table t1;
drop table t1;
##################################################################
###test modify column from null to not-null int
#################################################################
--echo "test modify column from nul to not-null"
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(id int primary key, c1 int, c2 varchar(100), c3 int) engine=xengine;
insert into t1 values(1,11,'abc',111);
insert into t1 values(2,12,'abc',222);
insert into t1 values(3,13,'abc',333);
# set the wait point to insert key2
connection default;
set @save_sql_mode = @@sql_mode;
set sql_mode = "STRICT_TRANS_TABLES";
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml_insert WAIT_FOR start_dml_insert_finish';
send alter table t1 modify column c1 int not null ,ALGORITHM = INPLACE, LOCK=DEFAULT;
--echo # Switch to connection con1
connection con1;
# insert key2
# wait the create sk ddl enter the inplace_create_sk_scan_base_begin point
SET DEBUG_SYNC= 'now WAIT_FOR start_dml_insert';
insert into t1 values(6,6,'6666',6),(7,7,'777777',7);
select * from t1;
update t1 set c1=null where id > 6;
select * from t1;
delete from t1 where id=1;
select * from t1;
# signal create sk ddl the key2 has been inserted
SET DEBUG_SYNC= 'now SIGNAL start_dml_insert_finish';
--echo # Switch to connection default
connection default;
# receive the result of alter table, expected create index fail
--error 1138
reap;
set sql_mode = @save_sql_mode;
check table t1;
select * from t1;
show create table t1;
drop table t1;
##################################################################
###test modify column from null to not-null varchar
#################################################################
--echo "test modify column from nul to not-null"
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1(id int primary key, c1 int, c2 varchar(100), c3 int) engine=xengine;
insert into t1 values(1,11,'abc',111);
insert into t1 values(2,12,'abc',222);
insert into t1 values(3,13,'abc',333);
# set the wait point to insert key2
connection default;
set @save_sql_mode = @@sql_mode;
set sql_mode = "STRICT_TRANS_TABLES";
SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml_insert WAIT_FOR start_dml_insert_finish';
send alter table t1 modify column c2 varchar(100) not null ,ALGORITHM = INPLACE, LOCK=DEFAULT;
--echo # Switch to connection con1
connection con1;
# insert key2
# wait the create sk ddl enter the inplace_create_sk_scan_base_begin point
SET DEBUG_SYNC= 'now WAIT_FOR start_dml_insert';
insert into t1 values(6,6,'6666',6),(7,7,'777777',7);
select * from t1;
update t1 set c2=null where id > 6;
select * from t1;
update t1 set c1=99 where id > 6;
select * from t1;
delete from t1 where id=1;
select * from t1;
# signal create sk ddl the key2 has been inserted
SET DEBUG_SYNC= 'now SIGNAL start_dml_insert_finish';
--echo # Switch to connection default
connection default;
# receive the result of alter table, expected create index fail
--error 1138
reap;
set sql_mode = @save_sql_mode;
check table t1;
select * from t1;
show create table t1;
drop table t1;
##################################################################
###test add pk
#################################################################
#--echo "test add pk"
#--disable_warnings
#drop table if exists t1;
#--enable_warnings
#create table t1(id int not null, c1 int, c2 varchar(100), c3 int) engine=xengine;
#insert into t1 values(1,11,'abc',111);
#insert into t1 values(2,12,'abc',222);
#insert into t1 values(3,13,'abc',333);
#
## set the wait point to insert key2
#connection default;
#SET DEBUG_SYNC= 'xengine.inplace_copy_ddl_scan_base_begin SIGNAL start_dml_insert WAIT_FOR start_dml_insert_finish';
#send alter table t1 add primary key(id) ,ALGORITHM = INPLACE, LOCK=DEFAULT;
#
# --echo # Switch to connection con1
# connection con1;
# # insert key2
# # wait the create sk ddl enter the inplace_create_sk_scan_base_begin point
# SET DEBUG_SYNC= 'now WAIT_FOR start_dml_insert';
# insert into t1 values(6,6,'6666',6),(7,7,'777777',7);
# select * from t1;
# update t1 set c2='aaaa' where id > 6;
# select * from t1;
# update t1 set c1=99 where id > 6;
# select * from t1;
# delete from t1 where id=1;
# select * from t1;
#
# # signal create sk ddl the key2 has been inserted
# SET DEBUG_SYNC= 'now SIGNAL start_dml_insert_finish';
#
#--echo # Switch to connection default
#connection default;
## receive the result of alter table, expected create index fail
#reap;
#
#check table t1;
#select * from t1;
#show create table t1;
#drop table t1;
--source suite/xengine/include/check_xengine_log_error.inc