summaryrefslogtreecommitdiff
path: root/mysql-test/suite/vcol/t/vcol_sql_mode_upgrade.test
blob: 71e34231ac12d111c01c4813a4f86bd6aad5125b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
-- source include/mysql_upgrade_preparation.inc
call mtr.add_suppression("Table rebuild required");

let $MYSQLD_DATADIR= `select @@datadir`;

--enable_prepare_warnings

--echo #
--echo # Opening a Maria-10.2.26 table with a stored VARCHAR column
--echo #

--echo # Copying maria100226_char_to_vchar_stored.* to MYSQLD_DATADIR
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYI $MYSQLD_DATADIR/test/t1.MYI

SHOW CREATE TABLE t1;
SHOW CREATE TABLE t1;
FLUSH TABLES;
SHOW CREATE TABLE t1;

FLUSH TABLES;
SELECT * FROM t1;
SELECT * FROM t1;
FLUSH TABLES;
SELECT * FROM t1;

--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t2 LIKE t1;
FLUSH TABLES;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t2 LIKE t1;

SHOW CREATE TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD b INT DEFAULT a;
SHOW CREATE TABLE t1;
SELECT * FROM t1;
FLUSH TABLES;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD c INT DEFAULT a;
SELECT * FROM t1;
DROP TABLE t1;


--echo #
--echo # Fixing a Maria-10.2.26 table with a stored VARCHAR column
--echo #

--echo # Fixing by dropping the generated stored column
--echo # Copying maria100226_char_to_vchar_stored.* to MYSQLD_DATADIR
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYI $MYSQLD_DATADIR/test/t1.MYI

ALTER TABLE t1 DROP v;
SELECT * FROM t1;
DROP TABLE t1;

--echo # Fixing by altering the generation expression of the stored column
--echo # Copying maria100226_char_to_vchar_stored.* to MYSQLD_DATADIR
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYI $MYSQLD_DATADIR/test/t1.MYI

SHOW CREATE TABLE t1;
ALTER TABLE t1 MODIFY v VARCHAR(5) AS (RTRIM(a)) PERSISTENT;
SHOW CREATE TABLE t1;
DROP TABLE t1;



--echo #
--echo # Opening a Maria-10.2.26 table with a virtual VARCHAR column
--echo #

--echo # Copying maria100226_char_to_vchar_virtual.* to MYSQLD_DATADIR
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI

SHOW CREATE TABLE t1;
SHOW CREATE TABLE t1;
FLUSH TABLES;
SHOW CREATE TABLE t1;

FLUSH TABLES;
SELECT * FROM t1;
SELECT * FROM t1;
FLUSH TABLES;
SELECT * FROM t1;

--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t2 LIKE t1;
FLUSH TABLES;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t2 LIKE t1;


SHOW CREATE TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD b INT DEFAULT a;
FLUSH TABLES;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD c INT DEFAULT a;
SELECT * FROM t1;
DROP TABLE t1;


--echo #
--echo # Fixing a Maria-10.2.26 table with a virtual VARCHAR column
--echo #

--echo # Fixing by dropping the virtual column
--echo # Copying maria100226_char_to_vchar_virtual.* to MYSQLD_DATADIR
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI

SHOW CREATE TABLE t1;
ALTER TABLE t1 DROP v;
SELECT * FROM t1;
DROP TABLE t1;

--echo # Fixing by dropping a key on a virtual column, using ALTER TABLE
--echo # Copying maria100226_char_to_vchar_virtual.* to MYSQLD_DATADIR
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI

SHOW CREATE TABLE t1;
ALTER TABLE t1 DROP KEY v;
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;


--echo # Fixing by dropping a key on a virtual column, using DROP INDEX
--echo # Copying maria100226_char_to_vchar_virtual.* to MYSQLD_DATADIR
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI

DROP INDEX v ON t1;
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;


--echo # Fixing by altering the generation expression of a virtual column
--echo # Copying maria100226_char_to_vchar_virtual.* to MYSQLD_DATADIR
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI

SHOW CREATE TABLE t1;
ALTER TABLE t1 MODIFY v VARCHAR(5) AS(RTRIM(a)) VIRTUAL;
SHOW CREATE TABLE t1;
SELECT * FROM t1;
CREATE TABLE t2 LIKE t1;
SHOW CREATE TABLE t2;
DROP TABLE t2;
DROP TABLE t1;


--echo #
--echo # Upgrading a Maria-10.2.26 table with a stored column
--echo #

--echo # Copying maria100226_char_to_varchar.* to MYSQLD_DATADIR
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_stored.MYI $MYSQLD_DATADIR/test/t1.MYI

CHECK TABLE t1 FOR UPGRADE;
FLUSH TABLES;
CHECK TABLE t1 FOR UPGRADE;
DROP TABLE t1;


--echo #
--echo # Upgrading a Maria-10.2.26 table with a virtual column
--echo #

--echo # Copying maria100226_char_to_varchar.* to MYSQLD_DATADIR
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/vcol_upgrade/maria100226_char_to_vchar_virtual.MYI $MYSQLD_DATADIR/test/t1.MYI

CHECK TABLE t1 FOR UPGRADE;
FLUSH TABLES;
CHECK TABLE t1 FOR UPGRADE;
DROP TABLE t1;