Skip to content

Commit 6567a94

Browse files
committed
MDEV-13134: Merge tests to innodb.alter_algorithm
Remove the separate test innodb.alter_instant, because it can be easily mistaken for innodb.instant_alter, which in turn is covering various instant ALTER TABLE operations.
1 parent 862af4d commit 6567a94

12 files changed

+348
-284
lines changed

mysql-test/suite/innodb/include/alter_nocopy.inc

Lines changed: 0 additions & 33 deletions
This file was deleted.

mysql-test/suite/innodb/include/alter_nocopy_fail.inc

Lines changed: 0 additions & 51 deletions
This file was deleted.

mysql-test/suite/innodb/r/alter_algorithm,INPLACE.rdiff

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,9 @@
6464
DROP TABLE t1;
6565
affected rows: 0
6666
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
67-
@@ -58,23 +58,23 @@
67+
@@ -57,22 +57,22 @@
68+
FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB;
6869
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
69-
SELECT @@alter_algorithm;
70-
@@alter_algorithm
71-
-COPY
72-
+INPLACE
7370
ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1;
7471
-affected rows: 1
7572
-info: Records: 1 Duplicates: 0 Warnings: 0
@@ -99,3 +96,59 @@
9996
+info: Records: 0 Duplicates: 0 Warnings: 0
10097
DROP TABLE t2, t1;
10198
affected rows: 0
99+
CREATE TABLE t1(f1 INT NOT NULL,
100+
@@ -85,27 +85,27 @@
101+
INSERT INTO t1(f1, f2) VALUES(1, 1);
102+
# Add column at the end of the table
103+
ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL';
104+
-affected rows: 1
105+
-info: Records: 1 Duplicates: 0 Warnings: 0
106+
+affected rows: 0
107+
+info: Records: 0 Duplicates: 0 Warnings: 0
108+
# Change virtual column expression
109+
ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL;
110+
-affected rows: 1
111+
-info: Records: 1 Duplicates: 0 Warnings: 0
112+
+affected rows: 0
113+
+info: Records: 0 Duplicates: 0 Warnings: 0
114+
# Add virtual column
115+
ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL;
116+
-affected rows: 1
117+
-info: Records: 1 Duplicates: 0 Warnings: 0
118+
+affected rows: 0
119+
+info: Records: 0 Duplicates: 0 Warnings: 0
120+
# Rename Column
121+
ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL;
122+
-affected rows: 1
123+
-info: Records: 1 Duplicates: 0 Warnings: 0
124+
+affected rows: 0
125+
+info: Records: 0 Duplicates: 0 Warnings: 0
126+
# Rename table
127+
ALTER TABLE t1 RENAME t3;
128+
affected rows: 0
129+
# Drop Virtual Column
130+
ALTER TABLE t3 DROP COLUMN vcol;
131+
-affected rows: 1
132+
-info: Records: 1 Duplicates: 0 Warnings: 0
133+
+affected rows: 0
134+
+info: Records: 0 Duplicates: 0 Warnings: 0
135+
# Column length varies
136+
ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20);
137+
affected rows: 0
138+
@@ -113,12 +113,12 @@
139+
SET foreign_key_checks = 0;
140+
affected rows: 0
141+
ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1);
142+
-affected rows: 1
143+
-info: Records: 1 Duplicates: 0 Warnings: 0
144+
+affected rows: 0
145+
+info: Records: 0 Duplicates: 0 Warnings: 0
146+
SET foreign_key_checks = 1;
147+
affected rows: 0
148+
ALTER TABLE t3 DROP FOREIGN KEY fidx;
149+
-affected rows: 1
150+
-info: Records: 1 Duplicates: 0 Warnings: 0
151+
+affected rows: 0
152+
+info: Records: 0 Duplicates: 0 Warnings: 0
153+
DROP TABLE t3, t2;
154+
affected rows: 0

mysql-test/suite/innodb/r/alter_algorithm,INSTANT.rdiff

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,9 @@
5555
DROP TABLE t1;
5656
affected rows: 0
5757
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
58-
@@ -58,23 +49,18 @@
58+
@@ -57,22 +48,17 @@
59+
FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB;
5960
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
60-
SELECT @@alter_algorithm;
61-
@@alter_algorithm
62-
-COPY
63-
+INSTANT
6461
ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1;
6562
-affected rows: 1
6663
-info: Records: 1 Duplicates: 0 Warnings: 0
@@ -85,3 +82,59 @@
8582
+ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY
8683
DROP TABLE t2, t1;
8784
affected rows: 0
85+
CREATE TABLE t1(f1 INT NOT NULL,
86+
@@ -85,27 +71,27 @@
87+
INSERT INTO t1(f1, f2) VALUES(1, 1);
88+
# Add column at the end of the table
89+
ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL';
90+
-affected rows: 1
91+
-info: Records: 1 Duplicates: 0 Warnings: 0
92+
+affected rows: 0
93+
+info: Records: 0 Duplicates: 0 Warnings: 0
94+
# Change virtual column expression
95+
ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL;
96+
-affected rows: 1
97+
-info: Records: 1 Duplicates: 0 Warnings: 0
98+
+affected rows: 0
99+
+info: Records: 0 Duplicates: 0 Warnings: 0
100+
# Add virtual column
101+
ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL;
102+
-affected rows: 1
103+
-info: Records: 1 Duplicates: 0 Warnings: 0
104+
+affected rows: 0
105+
+info: Records: 0 Duplicates: 0 Warnings: 0
106+
# Rename Column
107+
ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL;
108+
-affected rows: 1
109+
-info: Records: 1 Duplicates: 0 Warnings: 0
110+
+affected rows: 0
111+
+info: Records: 0 Duplicates: 0 Warnings: 0
112+
# Rename table
113+
ALTER TABLE t1 RENAME t3;
114+
affected rows: 0
115+
# Drop Virtual Column
116+
ALTER TABLE t3 DROP COLUMN vcol;
117+
-affected rows: 1
118+
-info: Records: 1 Duplicates: 0 Warnings: 0
119+
+affected rows: 0
120+
+info: Records: 0 Duplicates: 0 Warnings: 0
121+
# Column length varies
122+
ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20);
123+
affected rows: 0
124+
@@ -113,12 +99,12 @@
125+
SET foreign_key_checks = 0;
126+
affected rows: 0
127+
ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1);
128+
-affected rows: 1
129+
-info: Records: 1 Duplicates: 0 Warnings: 0
130+
+affected rows: 0
131+
+info: Records: 0 Duplicates: 0 Warnings: 0
132+
SET foreign_key_checks = 1;
133+
affected rows: 0
134+
ALTER TABLE t3 DROP FOREIGN KEY fidx;
135+
-affected rows: 1
136+
-info: Records: 1 Duplicates: 0 Warnings: 0
137+
+affected rows: 0
138+
+info: Records: 0 Duplicates: 0 Warnings: 0
139+
DROP TABLE t3, t2;
140+
affected rows: 0

mysql-test/suite/innodb/r/alter_algorithm,NOCOPY.rdiff

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,9 @@
5555
DROP TABLE t1;
5656
affected rows: 0
5757
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
58-
@@ -58,23 +49,23 @@
58+
@@ -57,22 +48,22 @@
59+
FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB;
5960
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
60-
SELECT @@alter_algorithm;
61-
@@alter_algorithm
62-
-COPY
63-
+NOCOPY
6461
ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1;
6562
-affected rows: 1
6663
-info: Records: 1 Duplicates: 0 Warnings: 0
@@ -90,3 +87,59 @@
9087
+info: Records: 0 Duplicates: 0 Warnings: 0
9188
DROP TABLE t2, t1;
9289
affected rows: 0
90+
CREATE TABLE t1(f1 INT NOT NULL,
91+
@@ -85,27 +76,27 @@
92+
INSERT INTO t1(f1, f2) VALUES(1, 1);
93+
# Add column at the end of the table
94+
ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL';
95+
-affected rows: 1
96+
-info: Records: 1 Duplicates: 0 Warnings: 0
97+
+affected rows: 0
98+
+info: Records: 0 Duplicates: 0 Warnings: 0
99+
# Change virtual column expression
100+
ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL;
101+
-affected rows: 1
102+
-info: Records: 1 Duplicates: 0 Warnings: 0
103+
+affected rows: 0
104+
+info: Records: 0 Duplicates: 0 Warnings: 0
105+
# Add virtual column
106+
ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL;
107+
-affected rows: 1
108+
-info: Records: 1 Duplicates: 0 Warnings: 0
109+
+affected rows: 0
110+
+info: Records: 0 Duplicates: 0 Warnings: 0
111+
# Rename Column
112+
ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL;
113+
-affected rows: 1
114+
-info: Records: 1 Duplicates: 0 Warnings: 0
115+
+affected rows: 0
116+
+info: Records: 0 Duplicates: 0 Warnings: 0
117+
# Rename table
118+
ALTER TABLE t1 RENAME t3;
119+
affected rows: 0
120+
# Drop Virtual Column
121+
ALTER TABLE t3 DROP COLUMN vcol;
122+
-affected rows: 1
123+
-info: Records: 1 Duplicates: 0 Warnings: 0
124+
+affected rows: 0
125+
+info: Records: 0 Duplicates: 0 Warnings: 0
126+
# Column length varies
127+
ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20);
128+
affected rows: 0
129+
@@ -113,12 +104,12 @@
130+
SET foreign_key_checks = 0;
131+
affected rows: 0
132+
ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1);
133+
-affected rows: 1
134+
-info: Records: 1 Duplicates: 0 Warnings: 0
135+
+affected rows: 0
136+
+info: Records: 0 Duplicates: 0 Warnings: 0
137+
SET foreign_key_checks = 1;
138+
affected rows: 0
139+
ALTER TABLE t3 DROP FOREIGN KEY fidx;
140+
-affected rows: 1
141+
-info: Records: 1 Duplicates: 0 Warnings: 0
142+
+affected rows: 0
143+
+info: Records: 0 Duplicates: 0 Warnings: 0
144+
DROP TABLE t3, t2;
145+
affected rows: 0

mysql-test/suite/innodb/r/alter_algorithm.result

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,11 @@ CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
5151
f3 INT AS (f2 * f2) VIRTUAL,
5252
f4 INT NOT NULL UNIQUE,
5353
f5 INT NOT NULL,
54-
INDEX`idx`(f2))ENGINE=INNODB;
54+
INDEX idx(f2))ENGINE=INNODB;
5555
CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL,
5656
INDEX(f1),
57-
FOREIGN KEY `fidx` (f1) REFERENCES t1(f1))ENGINE=INNODB;
57+
FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB;
5858
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
59-
SELECT @@alter_algorithm;
60-
@@alter_algorithm
61-
COPY
6259
ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1;
6360
affected rows: 1
6461
info: Records: 1 Duplicates: 0 Warnings: 0
@@ -78,3 +75,50 @@ affected rows: 1
7875
info: Records: 1 Duplicates: 0 Warnings: 0
7976
DROP TABLE t2, t1;
8077
affected rows: 0
78+
CREATE TABLE t1(f1 INT NOT NULL,
79+
f2 INT NOT NULL,
80+
f3 INT AS (f2 * f2) VIRTUAL,
81+
INDEX idx (f2))engine=innodb;
82+
CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL,
83+
f3 VARCHAR(10),
84+
INDEX(f1))ENGINE=INNODB;
85+
INSERT INTO t1(f1, f2) VALUES(1, 1);
86+
# Add column at the end of the table
87+
ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL';
88+
affected rows: 1
89+
info: Records: 1 Duplicates: 0 Warnings: 0
90+
# Change virtual column expression
91+
ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL;
92+
affected rows: 1
93+
info: Records: 1 Duplicates: 0 Warnings: 0
94+
# Add virtual column
95+
ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL;
96+
affected rows: 1
97+
info: Records: 1 Duplicates: 0 Warnings: 0
98+
# Rename Column
99+
ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL;
100+
affected rows: 1
101+
info: Records: 1 Duplicates: 0 Warnings: 0
102+
# Rename table
103+
ALTER TABLE t1 RENAME t3;
104+
affected rows: 0
105+
# Drop Virtual Column
106+
ALTER TABLE t3 DROP COLUMN vcol;
107+
affected rows: 1
108+
info: Records: 1 Duplicates: 0 Warnings: 0
109+
# Column length varies
110+
ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20);
111+
affected rows: 0
112+
info: Records: 0 Duplicates: 0 Warnings: 0
113+
SET foreign_key_checks = 0;
114+
affected rows: 0
115+
ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1);
116+
affected rows: 1
117+
info: Records: 1 Duplicates: 0 Warnings: 0
118+
SET foreign_key_checks = 1;
119+
affected rows: 0
120+
ALTER TABLE t3 DROP FOREIGN KEY fidx;
121+
affected rows: 1
122+
info: Records: 1 Duplicates: 0 Warnings: 0
123+
DROP TABLE t3, t2;
124+
affected rows: 0

0 commit comments

Comments
 (0)