Skip to content

Commit d6d621c

Browse files
committed
MDEV-18819 ALTER_COLUMN_VCOL is not set for generated stored columns
1 parent 73c864b commit d6d621c

8 files changed

+21
-51
lines changed

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- alter_algorithm.result
22
+++ alter_algorithm.reject
3-
@@ -7,44 +7,44 @@
3+
@@ -7,40 +7,40 @@
44
INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
55
SELECT @@alter_algorithm;
66
@@alter_algorithm
@@ -18,12 +18,6 @@
1818
-affected rows: 1
1919
-info: Records: 1 Duplicates: 0 Warnings: 0
2020
+affected rows: 0
21-
+info: Records: 0 Duplicates: 0 Warnings: 0
22-
# Make existing column NON-NULLABLE
23-
ALTER TABLE t1 MODIFY f3 INT NOT NULL;
24-
-affected rows: 1
25-
-info: Records: 1 Duplicates: 0 Warnings: 0
26-
+affected rows: 0
2721
+info: Records: 0 Duplicates: 0 Warnings: 0
2822
# Drop Stored Column
2923
ALTER TABLE t1 DROP COLUMN f5;
@@ -64,7 +58,7 @@
6458
DROP TABLE t1;
6559
affected rows: 0
6660
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
67-
@@ -57,22 +57,22 @@
61+
@@ -53,22 +53,22 @@
6862
FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB;
6963
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
7064
ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1;
@@ -97,7 +91,7 @@
9791
DROP TABLE t2, t1;
9892
affected rows: 0
9993
CREATE TABLE t1(f1 INT NOT NULL,
100-
@@ -85,27 +85,27 @@
94+
@@ -81,27 +81,27 @@
10195
INSERT INTO t1(f1, f2) VALUES(1, 1);
10296
# Add column at the end of the table
10397
ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL';
@@ -135,7 +129,7 @@
135129
# Column length varies
136130
ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20);
137131
affected rows: 0
138-
@@ -113,12 +113,12 @@
132+
@@ -109,12 +109,12 @@
139133
SET foreign_key_checks = 0;
140134
affected rows: 0
141135
ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1);

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- alter_algorithm.result
22
+++ alter_algorithm.reject
3-
@@ -7,44 +7,35 @@
3+
@@ -7,40 +7,32 @@
44
INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
55
SELECT @@alter_algorithm;
66
@@alter_algorithm
@@ -16,11 +16,6 @@
1616
ALTER TABLE t1 MODIFY f2 INT;
1717
-affected rows: 1
1818
-info: Records: 1 Duplicates: 0 Warnings: 0
19-
+Got one of the listed errors
20-
# Make existing column NON-NULLABLE
21-
ALTER TABLE t1 MODIFY f3 INT NOT NULL;
22-
-affected rows: 1
23-
-info: Records: 1 Duplicates: 0 Warnings: 0
2419
+Got one of the listed errors
2520
# Drop Stored Column
2621
ALTER TABLE t1 DROP COLUMN f5;
@@ -55,7 +50,7 @@
5550
DROP TABLE t1;
5651
affected rows: 0
5752
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
58-
@@ -57,22 +48,17 @@
53+
@@ -53,22 +45,17 @@
5954
FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB;
6055
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
6156
ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1;
@@ -83,7 +78,7 @@
8378
DROP TABLE t2, t1;
8479
affected rows: 0
8580
CREATE TABLE t1(f1 INT NOT NULL,
86-
@@ -85,27 +71,27 @@
81+
@@ -81,27 +68,27 @@
8782
INSERT INTO t1(f1, f2) VALUES(1, 1);
8883
# Add column at the end of the table
8984
ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL';
@@ -121,7 +116,7 @@
121116
# Column length varies
122117
ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20);
123118
affected rows: 0
124-
@@ -113,12 +99,12 @@
119+
@@ -109,12 +96,12 @@
125120
SET foreign_key_checks = 0;
126121
affected rows: 0
127122
ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1);

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- alter_algorithm.result
22
+++ alter_algorithm.reject
3-
@@ -7,44 +7,35 @@
3+
@@ -7,40 +7,32 @@
44
INSERT INTO t1(f1, f2, f3) VALUES(1, 1, 1);
55
SELECT @@alter_algorithm;
66
@@alter_algorithm
@@ -16,11 +16,6 @@
1616
ALTER TABLE t1 MODIFY f2 INT;
1717
-affected rows: 1
1818
-info: Records: 1 Duplicates: 0 Warnings: 0
19-
+Got one of the listed errors
20-
# Make existing column NON-NULLABLE
21-
ALTER TABLE t1 MODIFY f3 INT NOT NULL;
22-
-affected rows: 1
23-
-info: Records: 1 Duplicates: 0 Warnings: 0
2419
+Got one of the listed errors
2520
# Drop Stored Column
2621
ALTER TABLE t1 DROP COLUMN f5;
@@ -55,7 +50,7 @@
5550
DROP TABLE t1;
5651
affected rows: 0
5752
CREATE TABLE t1(f1 INT PRIMARY KEY, f2 INT NOT NULL,
58-
@@ -57,22 +48,22 @@
53+
@@ -53,22 +45,22 @@
5954
FOREIGN KEY fidx(f1) REFERENCES t1(f1))ENGINE=INNODB;
6055
INSERT INTO t1(f1, f2, f4, f5) VALUES(1, 2, 3, 4);
6156
ALTER TABLE t1 ADD INDEX idx1(f4), page_compressed=1;
@@ -88,7 +83,7 @@
8883
DROP TABLE t2, t1;
8984
affected rows: 0
9085
CREATE TABLE t1(f1 INT NOT NULL,
91-
@@ -85,27 +76,27 @@
86+
@@ -81,27 +73,27 @@
9287
INSERT INTO t1(f1, f2) VALUES(1, 1);
9388
# Add column at the end of the table
9489
ALTER TABLE t1 ADD COLUMN f4 char(100) default 'BIG WALL';
@@ -126,7 +121,7 @@
126121
# Column length varies
127122
ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20);
128123
affected rows: 0
129-
@@ -113,12 +104,12 @@
124+
@@ -109,12 +101,12 @@
130125
SET foreign_key_checks = 0;
131126
affected rows: 0
132127
ALTER TABLE t3 ADD FOREIGN KEY fidx(f2) REFERENCES t2(f1);

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ info: Records: 1 Duplicates: 0 Warnings: 0
1717
ALTER TABLE t1 MODIFY f2 INT;
1818
affected rows: 1
1919
info: Records: 1 Duplicates: 0 Warnings: 0
20-
# Make existing column NON-NULLABLE
21-
ALTER TABLE t1 MODIFY f3 INT NOT NULL;
22-
affected rows: 1
23-
info: Records: 1 Duplicates: 0 Warnings: 0
2420
# Drop Stored Column
2521
ALTER TABLE t1 DROP COLUMN f5;
2622
affected rows: 1

mysql-test/suite/innodb/r/innodb-alter-nullable.result

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ INSERT INTO t3 SET c=NULL;
9696
SET @old_sql_mode = @@sql_mode;
9797
SET sql_mode = '';
9898
ALTER TABLE t1 MODIFY c INT NOT NULL;
99-
affected rows: 0
100-
info: Records: 0 Duplicates: 0 Warnings: 1
99+
affected rows: 1
100+
info: Records: 1 Duplicates: 0 Warnings: 1
101101
Warnings:
102102
Warning 1265 Data truncated for column 'c' at row 1
103103
ALTER TABLE t2 MODIFY c INT NOT NULL;
@@ -111,10 +111,9 @@ info: Records: 1 Duplicates: 0 Warnings: 1
111111
Warnings:
112112
Warning 1265 Data truncated for column 'c' at row 1
113113
SET sql_mode = @old_sql_mode;
114-
# MDEV-18819 FIXME: Wrong result g=NULL
115114
SELECT * FROM t1;
116115
c g
117-
0 NULL
116+
0 0
118117
SELECT * FROM t2;
119118
c v
120119
0 0
@@ -137,8 +136,8 @@ INSERT INTO t1 SET c=NULL;
137136
INSERT INTO t2 SET c=NULL;
138137
INSERT INTO t3 SET c=NULL;
139138
ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
140-
affected rows: 0
141-
info: Records: 0 Duplicates: 0 Warnings: 1
139+
affected rows: 1
140+
info: Records: 1 Duplicates: 0 Warnings: 1
142141
Warnings:
143142
Warning 1265 Data truncated for column 'c' at row 1
144143
ALTER IGNORE TABLE t2 MODIFY c INT NOT NULL;
@@ -151,10 +150,9 @@ affected rows: 1
151150
info: Records: 1 Duplicates: 0 Warnings: 1
152151
Warnings:
153152
Warning 1265 Data truncated for column 'c' at row 1
154-
# MDEV-18819 FIXME: Wrong result g=NULL
155153
SELECT * FROM t1;
156154
c g
157-
0 NULL
155+
0 0
158156
SELECT * FROM t2;
159157
c v
160158
0 0
@@ -186,12 +184,11 @@ UPDATE t1 SET c=0;
186184
UPDATE t2 SET c=0;
187185
UPDATE t3 SET c=0;
188186
ALTER TABLE t1 MODIFY c INT NOT NULL;
189-
affected rows: 0
190-
info: Records: 0 Duplicates: 0 Warnings: 0
187+
affected rows: 1
188+
info: Records: 1 Duplicates: 0 Warnings: 0
191189
ALTER TABLE t2 MODIFY c INT NOT NULL;
192190
affected rows: 0
193191
info: Records: 0 Duplicates: 0 Warnings: 0
194-
# MDEV-18819 FIXME: This should not require ALGORITHM=COPY.
195192
ALTER TABLE t3 MODIFY c INT NOT NULL;
196193
affected rows: 1
197194
info: Records: 1 Duplicates: 0 Warnings: 0

mysql-test/suite/innodb/t/alter_algorithm.test

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ ALTER TABLE t1 ADD COLUMN col1 INT NOT NULL,DROP PRIMARY KEY,ADD PRIMARY KEY(col
3131
--error $error_code
3232
ALTER TABLE t1 MODIFY f2 INT;
3333

34-
--echo # Make existing column NON-NULLABLE
35-
--error $error_code
36-
ALTER TABLE t1 MODIFY f3 INT NOT NULL;
37-
3834
--echo # Drop Stored Column
3935
--error $error_code
4036
ALTER TABLE t1 DROP COLUMN f5;

mysql-test/suite/innodb/t/innodb-alter-nullable.test

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ ALTER TABLE t2 MODIFY c INT NOT NULL;
104104
ALTER TABLE t3 MODIFY c INT NOT NULL;
105105
--disable_info
106106
SET sql_mode = @old_sql_mode;
107-
--echo # MDEV-18819 FIXME: Wrong result g=NULL
108107
SELECT * FROM t1;
109108
SELECT * FROM t2;
110109
SELECT * FROM t3;
@@ -123,7 +122,6 @@ ALTER IGNORE TABLE t1 MODIFY c INT NOT NULL;
123122
ALTER IGNORE TABLE t2 MODIFY c INT NOT NULL;
124123
ALTER IGNORE TABLE t3 MODIFY c INT NOT NULL;
125124
--disable_info
126-
--echo # MDEV-18819 FIXME: Wrong result g=NULL
127125
SELECT * FROM t1;
128126
SELECT * FROM t2;
129127
SELECT * FROM t3;
@@ -151,7 +149,6 @@ UPDATE t3 SET c=0;
151149
--enable_info
152150
ALTER TABLE t1 MODIFY c INT NOT NULL;
153151
ALTER TABLE t2 MODIFY c INT NOT NULL;
154-
--echo # MDEV-18819 FIXME: This should not require ALGORITHM=COPY.
155152
ALTER TABLE t3 MODIFY c INT NOT NULL;
156153
--disable_info
157154
SELECT * FROM t1;

sql/sql_table.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6733,7 +6733,7 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar,
67336733
}
67346734

67356735
if (field->vcol_info->is_in_partitioning_expr() ||
6736-
field->flags & PART_KEY_FLAG)
6736+
field->flags & PART_KEY_FLAG || field->stored_in_db())
67376737
{
67386738
if (value_changes)
67396739
ha_alter_info->handler_flags|= ALTER_COLUMN_VCOL;

0 commit comments

Comments
 (0)