Skip to content

Commit

Permalink
tests: move around, add new
Browse files Browse the repository at this point in the history
two new tests:
* alter table times out because of a long concurrent trx
* alter table adds a column in the middle
  • Loading branch information
vuvova committed Aug 15, 2023
1 parent ab4bfad commit 6c57e29
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[standalone]
[nobinlog]
[binlog]
--log-bin=master-bin

3 changes: 3 additions & 0 deletions mysql-test/include/binlog_combinations.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Adds standalone and binlog combinations
#
2 changes: 0 additions & 2 deletions mysql-test/include/have_log_bin_off.require

This file was deleted.

2 changes: 0 additions & 2 deletions mysql-test/main/alter_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,6 @@ affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 1
Warnings:
Note 1831 Duplicate index `i3`. This is deprecated and will be disallowed in a future release
ALTER TABLE t1 ADD INDEX i4(b), ALGORITHM= COPY, LOCK= NONE;
ALTER TABLE t1 ADD INDEX i5(b), ALGORITHM= COPY, LOCK= SHARED;
affected rows: 2
info: Records: 2 Duplicates: 0 Warnings: 1
Expand All @@ -1750,7 +1749,6 @@ ALTER TABLE m1 ENABLE KEYS, ALGORITHM= INPLACE, LOCK= SHARED;
ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE
ALTER TABLE m1 ENABLE KEYS, ALGORITHM= INPLACE, LOCK= EXCLUSIVE;
affected rows: 0
ALTER TABLE m1 ENABLE KEYS, ALGORITHM= COPY, LOCK= NONE;
ALTER ONLINE TABLE m1 ADD COLUMN c int;
ERROR 0A000: LOCK=NONE is not supported for this operation. Try LOCK=SHARED
ALTER TABLE m1 ENABLE KEYS, ALGORITHM= COPY, LOCK= SHARED;
Expand Down
10 changes: 0 additions & 10 deletions mysql-test/main/alter_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -1517,12 +1517,6 @@ ALTER TABLE t1 DROP INDEX i1, DROP INDEX i2, DROP INDEX i3, DROP INDEX i4;
ALTER TABLE t1 ADD INDEX i1(b), ALGORITHM= INPLACE, LOCK= NONE;
ALTER TABLE t1 ADD INDEX i2(b), ALGORITHM= INPLACE, LOCK= SHARED;
ALTER TABLE t1 ADD INDEX i3(b), ALGORITHM= INPLACE, LOCK= EXCLUSIVE;
--disable_info
--disable_warnings
--error 0,ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1 ADD INDEX i4(b), ALGORITHM= COPY, LOCK= NONE;
--enable_warnings
--enable_info
ALTER TABLE t1 ADD INDEX i5(b), ALGORITHM= COPY, LOCK= SHARED;
ALTER TABLE t1 ADD INDEX i6(b), ALGORITHM= COPY, LOCK= EXCLUSIVE;

Expand All @@ -1531,10 +1525,6 @@ ALTER TABLE m1 ENABLE KEYS, ALGORITHM= INPLACE, LOCK= NONE;
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER TABLE m1 ENABLE KEYS, ALGORITHM= INPLACE, LOCK= SHARED;
ALTER TABLE m1 ENABLE KEYS, ALGORITHM= INPLACE, LOCK= EXCLUSIVE;
--disable_info
--error 0,ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE m1 ENABLE KEYS, ALGORITHM= COPY, LOCK= NONE;
--enable_info
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER ONLINE TABLE m1 ADD COLUMN c int;
# This works because the lock will be SNW for the copy phase.
Expand Down
2 changes: 0 additions & 2 deletions mysql-test/main/alter_table_online.combinations

This file was deleted.

72 changes: 57 additions & 15 deletions mysql-test/main/alter_table_online.result
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
set default_storage_engine= innodb;
connect con2, localhost, root,,;
connection default;
#
# Test insert
#
# Insert and add column
create or replace table t1 (a int) engine=innodb;
create or replace table t1 (a int);
insert t1 values (5);
connection con2;
set debug_sync= 'now WAIT_FOR ended';
Expand All @@ -21,8 +22,30 @@ a b
123 NULL
456 NULL
789 NULL
# long transaction and add column
create or replace table t1 (a int);
insert t1 values (5);
connection con2;
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;
alter table t1 add b int NULL, algorithm= copy, lock= none;
connection con2;
start transaction;
insert into t1 values (123), (456), (789);
set debug_sync= 'now SIGNAL end';
connection default;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select * from t1;
a
5
set session lock_wait_timeout=default;
connection con2;
rollback;
connection default;
# Insert and add NOT NULL column without default value
create or replace table t1 (a int) engine=innodb;
create or replace table t1 (a int);
insert t1 values (5);
connection con2;
set debug_sync= 'now WAIT_FOR ended';
Expand All @@ -44,7 +67,7 @@ a b
456 0
789 0
# Insert and add a column with a default value
create or replace table t1 (a int) engine=innodb;
create or replace table t1 (a int);
insert t1 values (5);
connection con2;
set debug_sync= 'now WAIT_FOR ended';
Expand All @@ -65,7 +88,7 @@ a b
# Test update
#
# Update and add a column
create or replace table t1 (a int primary key, b int) engine=innodb;
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 22);
insert t1 values (3, 44);
connection con2;
Expand All @@ -82,11 +105,29 @@ select * from t1;
a b c
1 55 1
3 44 1
# 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;
set debug_sync= 'now WAIT_FOR ended';
connection default;
set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
alter table t1 add c int default(1) after a,
algorithm= copy, lock= none;
connection con2;
update t1 set b= 55 where a = 1;
set debug_sync= 'now SIGNAL end';
connection default;
select * from t1;
a c b
1 1 55
3 1 44
#
# Test primary key change
#
# Drop key, add key
create or replace table t1 (a int primary key, b int) engine=innodb;
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 22);
insert t1 values (3, 44);
connection con2;
Expand All @@ -104,7 +145,7 @@ a b
3 44
1 55
# Drop key, add key. Two updates
create or replace table t1 (a int primary key, b int) engine=innodb;
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 11);
insert t1 values (2, 22);
connection con2;
Expand All @@ -125,7 +166,7 @@ a b
#
# Various tests, see below
#
create or replace table t1 (a int primary key, b int) engine=innodb;
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);
Expand Down Expand Up @@ -193,6 +234,7 @@ a b
9 99
#
# MYISAM. Only Inserts can be tested.
# (everything else is a table lock disallowing concurrent reads)
#
create or replace table t1 (a int) engine=myisam;
insert t1 values (5);
Expand All @@ -212,7 +254,7 @@ a b
456 NULL
789 NULL
# Test incompatible changes
create or replace table t1 (a int primary key, b int) engine=innodb;
create or replace table t1 (a int primary key, b int);
insert t1 values (1, 22);
insert t1 values (3, 44);
connection con2;
Expand All @@ -233,7 +275,7 @@ a b
# Test log read after EXCLUSIVE lock
# Transaction is started before ALTER, and UPDATE is made.
# Then more UPDATEs.
create or replace table t1 (a int primary key, b int) engine=innodb;
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);
Expand Down Expand Up @@ -265,7 +307,7 @@ a b
#
# Test progress report.
#
create or replace table t1 (a int primary key, b int) engine=innodb;
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);
Expand Down Expand Up @@ -364,7 +406,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=*SUBSTITUTED* DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
select *, UNIX_TIMESTAMP(row_start), UNIX_TIMESTAMP(row_end) from t1 for system_time all;
a b UNIX_TIMESTAMP(row_start) UNIX_TIMESTAMP(row_end)
1 55 1.000000 2147483647.999999
Expand All @@ -388,7 +430,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=*SUBSTITUTED* DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING
select *, UNIX_TIMESTAMP(row_start), UNIX_TIMESTAMP(row_end) from t1 for system_time all;
a b UNIX_TIMESTAMP(row_start) UNIX_TIMESTAMP(row_end)
1 55 1.000000 3.000000
Expand All @@ -412,7 +454,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=*SUBSTITUTED* DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
select * from t1;
a b
1 88
Expand All @@ -422,9 +464,9 @@ a b
#
# Test ROLLBACK TO SAVEPOINT
#
create or replace table t1 (a int) engine=innodb;
create or replace table t1 (a int);
insert t1 values (1), (2);
create or replace table t2 (a int) engine=innodb;
create or replace table t2 (a int);
insert t2 values (1), (2);
connection con2;
begin;
Expand Down
Loading

0 comments on commit 6c57e29

Please sign in to comment.