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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
set binlog_row_image="FULL";
set @@default_storage_engine="myisam";
create table t1 (a int, b int as (a+1), c int as (b+1) stored);
insert t1 set a=1;
select * from t1;
a b c
1 2 3
update t1 set a=2;
select * from t1;
a b c
2 3 4
drop table t1;
create table t1 (a int, c int as(a), p varchar(20) as(rtrim(y)), y char(20), index (p,c));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`c` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL,
`p` varchar(20) GENERATED ALWAYS AS (rtrim(`y`)) VIRTUAL,
`y` char(20) DEFAULT NULL,
KEY `p` (`p`,`c`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 (a,y) values(1, "yyy");
update t1 set a = 100 where a = 1;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (
a varchar(10000),
b varchar(3000),
c varchar(14000) generated always as (concat(a,b)) virtual,
d varchar(5000) generated always as (b) virtual,
e int(11) generated always as (10) virtual,
h int(11) not null primary key,
index(c(100), d(20)));
insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
update t1 set a = repeat(cast(1 as char), 2000);
drop table t1;
create table t1 (
a varchar(10000),
b varchar(3000),
c varchar(14000) generated always as (concat(a,b)) virtual,
i varchar(5000) generated always as (b) virtual,
d varchar(5000) generated always as (i) virtual,
e int(11) generated always as (10) virtual,
h int(11) not null primary key,
index(c(100), d(20)));
insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
update t1 set a = repeat(cast(1 as char), 2000);
drop table t1;
create table t1(a blob not null, b int, c varbinary (10) generated always as (a) virtual, unique (c(9)));
insert t1 (a,b) values ('a', 1);
replace t1 set a = 'a',b =1;
insert t1 (a,b) values ('a', 1) on duplicate key update a='b', b=2;
select * from t1;
a b c
b 2 b
drop table t1;
create table t (a int primary key, b int, c int as (b), index (c));
insert t (a,b) values (9,0);
create table t2 select * from t;
update t, t2 set t.b=10 where t.a=t2.a;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c
9 10 10
drop table t, t2;
create table t1 (a int, b int, c int, d int, e int);
insert t1 values (1,2,3,4,5), (1,2,3,4,5);
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
create table t (a int primary key,
b int, c blob as (b), index (c(57)),
d blob, e blob as (d), index (e(57)))
replace select * from t1;
Warnings:
Warning 1906 The value specified for generated column 'c' in table 't' has been ignored
Warning 1906 The value specified for generated column 'e' in table 't' has been ignored
Warning 1906 The value specified for generated column 'c' in table 't' has been ignored
Warning 1906 The value specified for generated column 'e' in table 't' has been ignored
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
1 2 2 4 4
update t set a=10, b=1, d=1;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 1 1 1 1
replace t (a,b,d) values (10,2,2);
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 2 2 2 2
insert t(a,b,d) values (10) on duplicate key update b=3;
ERROR 21S01: Column count doesn't match value count at row 1
insert t(a,b,d) values (10,2,2) on duplicate key update b=3, d=3;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 3 3 3 3
replace t (a,b,d) select 10,4,4;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 4 4 4 4
insert t(a,b,d) select 10,4,4 on duplicate key update b=5, d=5;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 5 5 5 5
replace delayed t (a,b,d) values (10,6,6);
flush tables;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 6 6 6 6
insert delayed t(a,b,d) values (10,6,6) on duplicate key update b=7, d=7;
flush tables;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 7 7 7 7
load data infile 'MYSQLTEST_VARDIR/tmp/vblobs.txt' replace into table t;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 8 8 8 8
update t set a=11, b=9, d=9 where a>5;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
11 9 9 9 9
create table t2 select * from t;
update t, t2 set t.b=10, t.d=10 where t.a=t2.a;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
11 10 10 10 10
update t, t tt set t.b=11, tt.d=11 where t.a=tt.a;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
11 11 11 11 11
drop table t, t1, t2;
create table t (f1 int, f2 int, f3 int as (f1*2) virtual, key(f3,f2));
insert into t (f1,f2) values (1,1),(2,2);
create view v as
select a2.f1, a2.f2, a1.f3
from t a1, t a2
where a2.f3 <> 0
with local check option;
update v set f3 = 52;
drop view v;
drop table t;
set binlog_row_image="MINIMAL";
create table t1 (a int, b int as (a+1), c int as (b+1) stored);
insert t1 set a=1;
select * from t1;
a b c
1 2 3
update t1 set a=2;
select * from t1;
a b c
2 3 4
drop table t1;
create table t1 (a int, c int as(a), p varchar(20) as(rtrim(y)), y char(20), index (p,c));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`c` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL,
`p` varchar(20) GENERATED ALWAYS AS (rtrim(`y`)) VIRTUAL,
`y` char(20) DEFAULT NULL,
KEY `p` (`p`,`c`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 (a,y) values(1, "yyy");
update t1 set a = 100 where a = 1;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (
a varchar(10000),
b varchar(3000),
c varchar(14000) generated always as (concat(a,b)) virtual,
d varchar(5000) generated always as (b) virtual,
e int(11) generated always as (10) virtual,
h int(11) not null primary key,
index(c(100), d(20)));
insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
update t1 set a = repeat(cast(1 as char), 2000);
drop table t1;
create table t1 (
a varchar(10000),
b varchar(3000),
c varchar(14000) generated always as (concat(a,b)) virtual,
i varchar(5000) generated always as (b) virtual,
d varchar(5000) generated always as (i) virtual,
e int(11) generated always as (10) virtual,
h int(11) not null primary key,
index(c(100), d(20)));
insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
update t1 set a = repeat(cast(1 as char), 2000);
drop table t1;
create table t1(a blob not null, b int, c varbinary (10) generated always as (a) virtual, unique (c(9)));
insert t1 (a,b) values ('a', 1);
replace t1 set a = 'a',b =1;
insert t1 (a,b) values ('a', 1) on duplicate key update a='b', b=2;
select * from t1;
a b c
b 2 b
drop table t1;
create table t (a int primary key, b int, c int as (b), index (c));
insert t (a,b) values (9,0);
create table t2 select * from t;
update t, t2 set t.b=10 where t.a=t2.a;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c
9 10 10
drop table t, t2;
create table t1 (a int, b int, c int, d int, e int);
insert t1 values (1,2,3,4,5), (1,2,3,4,5);
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
create table t (a int primary key,
b int, c blob as (b), index (c(57)),
d blob, e blob as (d), index (e(57)))
replace select * from t1;
Warnings:
Warning 1906 The value specified for generated column 'c' in table 't' has been ignored
Warning 1906 The value specified for generated column 'e' in table 't' has been ignored
Warning 1906 The value specified for generated column 'c' in table 't' has been ignored
Warning 1906 The value specified for generated column 'e' in table 't' has been ignored
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
1 2 2 4 4
update t set a=10, b=1, d=1;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 1 1 1 1
replace t (a,b,d) values (10,2,2);
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 2 2 2 2
insert t(a,b,d) values (10) on duplicate key update b=3;
ERROR 21S01: Column count doesn't match value count at row 1
insert t(a,b,d) values (10,2,2) on duplicate key update b=3, d=3;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 3 3 3 3
replace t (a,b,d) select 10,4,4;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 4 4 4 4
insert t(a,b,d) select 10,4,4 on duplicate key update b=5, d=5;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 5 5 5 5
replace delayed t (a,b,d) values (10,6,6);
flush tables;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 6 6 6 6
insert delayed t(a,b,d) values (10,6,6) on duplicate key update b=7, d=7;
flush tables;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 7 7 7 7
load data infile 'MYSQLTEST_VARDIR/tmp/vblobs.txt' replace into table t;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
10 8 8 8 8
update t set a=11, b=9, d=9 where a>5;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
11 9 9 9 9
create table t2 select * from t;
update t, t2 set t.b=10, t.d=10 where t.a=t2.a;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
11 10 10 10 10
update t, t tt set t.b=11, tt.d=11 where t.a=tt.a;
check table t;
Table Op Msg_type Msg_text
test.t check status OK
select * from t;
a b c d e
11 11 11 11 11
drop table t, t1, t2;
create table t (f1 int, f2 int, f3 int as (f1*2) virtual, key(f3,f2));
insert into t (f1,f2) values (1,1),(2,2);
create view v as
select a2.f1, a2.f2, a1.f3
from t a1, t a2
where a2.f3 <> 0
with local check option;
update v set f3 = 52;
drop view v;
drop table t;
|