Debian Codegraph @

mysql-test/suite/versioning/r/update.result

raw
1 create table t1(
2 x int unsigned,
3 y int unsigned,
4 sys_trx_start SYS_DATATYPE as row start invisible,
5 sys_trx_end SYS_DATATYPE as row end invisible,
6 period for system_time (sys_trx_start, sys_trx_end))
7 with system versioning;
8 insert into t1(x, y) values (1, 1000), (2, 2000), (3, 3000), (4, 4000), (5, 5000), (6, 6000), (7, 7000), (8, 8000), (9, 9000);
9 select x, y from t1 order by x, y;
10 x y
11 1 1000
12 2 2000
13 3 3000
14 4 4000
15 5 5000
16 6 6000
17 7 7000
18 8 8000
19 9 9000
20 update t1 set y = y + 1 where x > 7;
21 select x, y from t1 order by x, y;
22 x y
23 1 1000
24 2 2000
25 3 3000
26 4 4000
27 5 5000
28 6 6000
29 7 7000
30 8 8001
31 9 9001
32 select x, y from t1 for system_time all order by sys_trx_end, x, y;
33 x y
34 8 8000
35 9 9000
36 1 1000
37 2 2000
38 3 3000
39 4 4000
40 5 5000
41 6 6000
42 7 7000
43 8 8001
44 9 9001
45 drop table t1;
46 create table t1 (
47 id bigint primary key,
48 x int,
49 y int without system versioning,
50 sys_trx_start SYS_DATATYPE as row start invisible,
51 sys_trx_end SYS_DATATYPE as row end invisible,
52 period for system_time (sys_trx_start, sys_trx_end))
53 with system versioning;
54 set timestamp= unix_timestamp('2000-01-01 00:00:00');
55 insert into t1 values(1, 1, 1);
56 select sys_trx_start into @tmp1 from t1;
57 set timestamp= unix_timestamp('2000-01-01 01:00:00');
58 update t1 set x= 11, y= 11 where id = 1;
59 select @tmp1 < sys_trx_start as A1, x, y from t1;
60 A1 x y
61 1 11 11
62 select sys_trx_start into @tmp1 from t1;
63 set timestamp= unix_timestamp('2000-01-01 02:00:00');
64 update t1 set y= 1 where id = 1;
65 select @tmp1 = sys_trx_start as A2, x from t1;
66 A2 x
67 1 11
68 drop table t1;
69 set timestamp= default;
70 create table t1 (
71 x int,
72 y int,
73 sys_trx_start SYS_DATATYPE as row start invisible,
74 sys_trx_end SYS_DATATYPE as row end invisible,
75 period for system_time (sys_trx_start, sys_trx_end)
76 ) with system versioning;
77 insert into t1 (x, y) values (1, 1), (2, 1), (3, 1), (4, 1), (5, 1);
78 start transaction;
79 update t1 set y= y + 1 where x = 3;
80 update t1 set y= y + 1 where x = 2;
81 update t1 set y= y + 1 where x = 3;
82 update t1 set y= y + 1 where x > 3;
83 update t1 set y= y + 1 where x > 4;
84 commit;
85 select x, y, sys_trx_end = MAXVAL as current from t1 for system_time all order by sys_trx_end, x, y;
86 x y current
87 3 1 0
88 2 1 0
89 3 2 0
90 4 1 0
91 5 1 0
92 5 2 0
93 1 1 1
94 2 2 1
95 3 3 1
96 4 2 1
97 5 3 1
98 drop table t1;
99 create table t1 (
100 id int primary key auto_increment,
101 x int,
102 sys_trx_start SYS_DATATYPE as row start invisible,
103 sys_trx_end SYS_DATATYPE as row end invisible,
104 period for system_time (sys_trx_start, sys_trx_end))
105 with system versioning;
106 set @t0= now(6);
107 insert into t1 (x) values (1);
108 set @t1= now(6);
109 update t1 set x= 2 where id = 1;
110 set @t2= now(6);
111 update t1 set x= 3 where id = 1;
112 select x from t1 for system_time as of timestamp @t0;
113 x
114 select x from t1 for system_time as of timestamp @t1;
115 x
116 1
117 select x from t1 for system_time as of timestamp @t2;
118 x
119 2
120 select x from t1 for system_time as of timestamp now(6);
121 x
122 3
123 drop table t1;
124 create table t1(
125 x int unsigned,
126 sys_trx_end SYS_DATATYPE as row end invisible,
127 sys_trx_start SYS_DATATYPE as row start invisible,
128 y int unsigned,
129 period for system_time (sys_trx_start, sys_trx_end),
130 primary key(x, y))
131 with system versioning;
132 insert into t1(x, y) values (1, 1000), (3, 3000), (4, 4000), (5, 5000);
133 insert into t1(x, y) values(3, 3000) on duplicate key update y = y+1;
134 insert into t1(x, y) values(4, 4444) on duplicate key update y = y+1;
135 select x, y from t1 for system_time all order by sys_trx_end, x, y;
136 x y
137 3 3000
138 1 1000
139 3 3001
140 4 4000
141 4 4444
142 5 5000
143 select x, y from t1 order by x, y;
144 x y
145 1 1000
146 3 3001
147 4 4000
148 4 4444
149 5 5000
150 drop table t1;
151 create table t1 (
152 x int unsigned,
153 y int unsigned,
154 sys_trx_start SYS_DATATYPE as row start invisible,
155 sys_trx_end SYS_DATATYPE as row end invisible,
156 period for system_time (sys_trx_start, sys_trx_end))
157 with system versioning;
158 create table t2 like t1;
159 insert into t1(x, y) values (1, 1000), (2, 2000), (3, 3000), (4, 4000), (5, 5000), (6, 6000), (7, 7000), (8, 8000), (9, 9000);
160 insert into t2(x, y) values (1, 1010), (2, 2010), (3, 3010), (4, 4010), (5, 5010), (6, 6010), (7, 7010), (8, 8010), (9, 9010);
161 update t1, t2 set t1.y = t1.x + t1.y, t2.y = t2.x + t2.y where t1.x > 7 and t2.x < 7;
162 select x, y from t1 for system_time all order by sys_trx_end, x, y;
163 x y
164 8 8000
165 9 9000
166 1 1000
167 2 2000
168 3 3000
169 4 4000
170 5 5000
171 6 6000
172 7 7000
173 8 8008
174 9 9009
175 select x, y from t1 order by x, y;
176 x y
177 1 1000
178 2 2000
179 3 3000
180 4 4000
181 5 5000
182 6 6000
183 7 7000
184 8 8008
185 9 9009
186 select x, y from t2 for system_time all order by sys_trx_end, x, y;
187 x y
188 1 1010
189 2 2010
190 3 3010
191 4 4010
192 5 5010
193 6 6010
194 1 1011
195 2 2012
196 3 3013
197 4 4014
198 5 5015
199 6 6016
200 7 7010
201 8 8010
202 9 9010
203 select x, y from t2 order by x, y;
204 x y
205 1 1011
206 2 2012
207 3 3013
208 4 4014
209 5 5015
210 6 6016
211 7 7010
212 8 8010
213 9 9010
214 drop table t1;
215 drop table t2;
216 create table t1 (
217 id bigint primary key without system versioning,
218 name varchar(128),
219 salary bigint without system versioning,
220 sys_trx_start SYS_DATATYPE as row start invisible,
221 sys_trx_end SYS_DATATYPE as row end invisible,
222 period for system_time (sys_trx_start, sys_trx_end))
223 with system versioning;
224 create table t2 like t1;
225 insert into t1 values (1, "Jeremy", 3000);
226 insert into t2 values (1, "Jeremy", 4000);
227 select sys_trx_start into @tmp1 from t1;
228 select sys_trx_start into @tmp2 from t2;
229 update t1, t2 set t1.name= "Jerry", t2.name= "Jerry" where t1.id = t2.id and t1.name = "Jeremy";
230 select @tmp1 < sys_trx_start as A1, name from t1;
231 A1 name
232 1 Jerry
233 select @tmp2 < sys_trx_start as A2, name from t2;
234 A2 name
235 1 Jerry
236 select sys_trx_start into @tmp1 from t1;
237 select sys_trx_start into @tmp2 from t2;
238 update t1, t2 set t1.salary= 2500, t2.salary= 2500 where t1.id = t2.id and t1.name = "Jerry";
239 select @tmp1 = sys_trx_start as B1, salary from t1;
240 B1 salary
241 1 2500
242 select @tmp2 = sys_trx_start as B2, salary from t2;
243 B2 salary
244 1 2500
245 drop table t1;
246 drop table t2;
247 # Ensure FTS retains correct history
248 create table t1 (
249 x int, y text, fulltext (y),
250 row_start SYS_DATATYPE as row start invisible,
251 row_end SYS_DATATYPE as row end invisible,
252 period for system_time (row_start, row_end))
253 with system versioning engine innodb;
254 insert into t1 values (1, repeat('LONG', 2048));
255 update t1 set x= x + 1;
256 select x, left(y, 4), length(y), check_row(row_start, row_end) from t1 for system_time all order by x, y;
257 x left(y, 4) length(y) check_row(row_start, row_end)
258 1 LONG 8192 HISTORICAL ROW
259 2 LONG 8192 CURRENT ROW
260 Warnings:
261 Warning 4202 2 values were longer than max_sort_length. Sorting used only the first 1024 bytes
262 update t1 set y= 'SHORT';
263 select x, left(y, 4), length(y), check_row(row_start, row_end) from t1 for system_time all order by x, y;
264 x left(y, 4) length(y) check_row(row_start, row_end)
265 1 LONG 8192 HISTORICAL ROW
266 2 LONG 8192 HISTORICAL ROW
267 2 SHOR 5 CURRENT ROW
268 Warnings:
269 Warning 4202 2 values were longer than max_sort_length. Sorting used only the first 1024 bytes
270 drop tables t1;
271 ### Issue tempesta-tech/mariadb#365, bug 7 (duplicate of historical row)
272 create or replace table t1 (a int primary key, b int)
273 with system versioning engine myisam;
274 insert into t1 (a) values (1);
275 replace t1 values (1,2),(1,3),(2,4);
276 #
277 # MDEV-14829 Assertion `0' failed in Protocol::end_statement upon concurrent UPDATE
278 #
279 set @old_lock_wait_timeout= @@innodb_lock_wait_timeout;
280 set @@innodb_lock_wait_timeout= 100000000;
281 create or replace table t1 (pk int, a char(3), b char(3), primary key(pk))
282 engine=innodb with system versioning;
283 insert into t1 (pk) values (1);
284 connect con1,localhost,root,,test;
285 start transaction;
286 select * from t1 for update;
287 pk a b
288 1 NULL NULL
289 connection default;
290 update t1 set b = 'foo';
291 connection con1;
292 update t1 set a = 'bar';
293 ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
294 disconnect con1;
295 connection default;
296 drop table t1;
297 set @@innodb_lock_wait_timeout= @old_lock_wait_timeout;
298 #
299 # MDEV-19406 Assertion on updating view of join with versioned table
300 #
301 create or replace table t1 (pk int primary key, a date, b int, index(b)) engine=innodb with system versioning;
302 create or replace table t2 (c int);
303 create or replace view v as select * from t1 join t2;
304 insert into t1 (pk) values (1);
305 update t1 set a= '2012-12-12';
306 update v set a= '2000-01-01' order by b limit 1;
307 drop view v;
308 drop table t1, t2;
309 #
310 # MDEV-20441 ER_CRASHED_ON_USAGE upon update on versioned Aria table
311 #
312 create or replace table t1 (a varchar(8))
313 engine=aria row_format=fixed
314 with system versioning;
315 insert into t1 (a) values ('foo');
316 update t1 set a = 'bar';
317 drop table t1;
318 #
319 # MDEV-21147 Assertion `marked_for_read()' upon UPDATE on versioned table via view
320 #
321 create or replace table t1 (
322 pk int, a char(8), b char(8),
323 primary key (pk)
324 ) with system versioning;
325 create or replace view v1 as select * from t1;
326 insert into t1 values (1, null, 'd') , (2, null, 'i') ;
327 update v1 set a= null where b = '';
328 create or replace table t1 (id int, k int, primary key (id)) engine=innodb with system versioning;
329 insert into t1 values (1,1),(2,2);
330 create or replace view v1 as select * from t1;
331 update v1 set id= 2 where k = 0;
332 create or replace table t1 (a int) with system versioning;
333 create or replace view v1 as select * from t1;
334 create or replace procedure sp() update v1 set xx = 1;
335 call sp;
336 ERROR 42S22: Unknown column 'xx' in 'SET'
337 call sp;
338 ERROR 42S22: Unknown column 'xx' in 'SET'
339 drop procedure sp;
340 drop view v1;
341 drop table t1;
342 #
343 # MDEV-21342 Assertion in set_ok_status() upon spatial field error on system-versioned table
344 #
345 create or replace table t1 (f point, key(f)) with system versioning engine=myisam;
346 insert t1 values (null);
347 update t1 set f = null where f = 'foo';
348 ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
349 drop table t1;
350 #
351 # MDEV-22061 InnoDB: Assertion of missing row in sec index row_start upon REPLACE on a system-versioned table
352 #
353 create or replace table t1 (
354 a int,
355 b int,
356 row_start bigint(20) unsigned generated always as row start,
357 row_end bigint(20) unsigned generated always as row end,
358 unique key (b,row_end),
359 key (row_start),
360 period for system_time (row_start,row_end)
361 ) engine=innodb with system versioning;
362 insert into t1 (a, b) values (1, 2);
363 replace into t1 (a, b) values (3, 2);
364 replace into t1 (a, b) values (4, 2);
365 drop table t1;
366 #
367 # MDEV-20661 Virtual fields are not recalculated on system fields value assignment
368 #
369 create table t1 (
370 a int,
371 row_start SYS_DATATYPE as row start invisible,
372 row_end SYS_DATATYPE as row end invisible,
373 period for system_time (row_start, row_end),
374 v1 bigint unsigned as (a ^ row_start) unique,
375 v2 bigint unsigned as (a ^ row_end) unique
376 ) engine=innodb with system versioning;
377 insert into t1 (a) values (1), (2);
378 update ignore t1 set a= 3;
379 delete history from t1;
380 drop table t1;
381 #
382 # MDEV-23446 UPDATE does not insert history row if the row is not changed
383 #
384 create table t1 (
385 a int,
386 row_start SYS_DATATYPE as row start invisible,
387 row_end SYS_DATATYPE as row end invisible,
388 period for system_time (row_start, row_end)) with system versioning;
389 insert into t1 values (1);
390 update t1 set a= 1;
391 select *, check_row(row_start, row_end) from t1 for system_time all order by row_end;
392 a check_row(row_start, row_end)
393 1 HISTORICAL ROW
394 1 CURRENT ROW
395 # multi-update
396 create or replace table t2 like t1;
397 create or replace table t3 like t1;
398 insert into t2 values (1);
399 insert into t3 values (1);
400 update t2, t3 set t2.a= 1, t3.a= 1 where t2.a = t3.a;
401 select *, check_row(row_start, row_end) from t2 for system_time all order by row_end;
402 a check_row(row_start, row_end)
403 1 HISTORICAL ROW
404 1 CURRENT ROW
405 select *, check_row(row_start, row_end) from t2 for system_time all order by row_end;
406 a check_row(row_start, row_end)
407 1 HISTORICAL ROW
408 1 CURRENT ROW
409 drop tables t1, t2, t3;
410 #
411 # MDEV-26778 row_start is not updated in current row for InnoDB
412 #
413 create or replace table t1 (x int) with system versioning;
414 insert t1 values (1);
415 update t1 set x= 1;
416 select row_start into @r from t1;
417 select check_row_ts(row_start, row_end) from t1 for system_time all where row_start = @r;
418 check_row_ts(row_start, row_end)
419 CURRENT ROW
420 drop table t1;
421 #
422 # MDEV-22973 Assertion in compare_record upon multi-update involving versioned table via view
423 #
424 create or replace table t1 (a int, primary key (a)) engine=myisam;
425 insert into t1 values (0);
426 create or replace table t2 (pk int, b int, primary key (pk), key(b)) engine=innodb with system versioning;
427 insert into t2 values (1, 0), (2, 0);
428 create or replace view v as select a, b from t1, t2;
429 update v set b= null where a = 0 order by b;
430 drop view v;
431 drop table t1, t2;
432 #
433 # MDEV-24522 Assertion `inited==NONE' fails upon UPDATE on versioned table with unique blob
434 #
435 create table t1 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
436 insert into t1 values (1, 1, 'foo'), (2, 11, 'bar');
437 update t1 set a = 3 where b <= 9;
438 update t1 set a = 3 where b <= 10;
439 drop table t1;
440 create table t1 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
441 create table t2 (a int, b int, c text, unique(c), key (b)) engine=myisam with system versioning;
442 insert into t1 values (1, 1, 'foo'), (2, 11, 'bar');
443 insert into t2 values (1, 1, 'foo'), (2, 11, 'bar');
444 update t1 set a = 3 where b <= 9;
445 update t2 set a = 3 where b <= 9;
446 update t1, t2 set t1.a = 3, t2.a = 3 where t1.b <= 10 and t2.b <= 10 and t1.b = t2.b;
447 drop tables t1, t2;
448 #
449 # MDEV-23100 ODKU of non-versioning column inserts history row
450 #
451 create table t1 (
452 x int unique,
453 y int without system versioning
454 ) with system versioning;
455 insert into t1 (x, y) values ('1', '1');
456 insert into t1 (x, y) values ('1', '2')
457 on duplicate key update y = 3;
458 select x, y, check_row_ts(row_start, row_end) from t1 for system_time all order by row_end;
459 x y check_row_ts(row_start, row_end)
460 1 3 CURRENT ROW
461 drop table t1;
462 #
463 # MDEV-25644 UPDATE not working properly on transaction precise system versioned table
464 #
465 create or replace table t1 (nid int primary key, nstate int, ntype int) engine innodb;
466 alter table t1 add
467 row_start SYS_DATATYPE generated always as row start invisible,
468 add row_end SYS_DATATYPE generated always as row end invisible,
469 add period for system_time(row_start, row_end),
470 add system versioning;
471 insert into t1 values (1, 1, 1);
472 select nid, nstate, check_row(row_start, row_end) from t1 for system_time all order by row_start, row_end;
473 nid nstate check_row(row_start, row_end)
474 1 1 CURRENT ROW
475 start transaction;
476 update t1 set nstate= nstate where nid = 1;
477 select nid, nstate, check_row(row_start, row_end) from t1 for system_time all order by row_start, row_end;
478 nid nstate check_row(row_start, row_end)
479 1 1 HISTORICAL ROW
480 1 1 CURRENT ROW
481 # Bug: ERROR 1761 (23000): Foreign key constraint for table 'xxx', record '1-18446744073709551615' would lead to a duplicate entry in table 'xxx', key 'PRIMARY'
482 update t1 set nstate= 3 where nid= 1;
483 select nid, nstate, check_row(row_start, row_end) from t1 for system_time all order by row_start, row_end;
484 nid nstate check_row(row_start, row_end)
485 1 1 HISTORICAL ROW
486 1 1 HISTORICAL ROW
487 1 3 CURRENT ROW
488 commit;
489 drop tables t1;
490 # End of 10.4 tests