File: delete_history.result

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (507 lines) | stat: -rw-r--r-- 19,695 bytes parent folder | download
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
call mtr.add_suppression("need more HISTORY partitions");
create table t (a int);
delete history from t before system_time now();
ERROR HY000: Table `t` is not system-versioned
create or replace table t (
a int,
row_start SYS_TYPE as row start invisible,
row_end SYS_TYPE as row end invisible,
period for system_time (row_start, row_end))
with system versioning;
insert into t values (1);
update t set a=2;
set @test = 'correct';
create trigger trg_before before delete on t for each row set @test = 'incorrect';
create trigger trg_after after delete on t for each row set @test = 'incorrect';
delete history from t;
select @test from t;
@test
correct
drop table t;
create or replace table t (
a int,
row_start SYS_TYPE as row start invisible,
row_end SYS_TYPE as row end invisible,
period for system_time (row_start, row_end))
with system versioning;
insert into t values (1), (2);
update t set a=11 where a=1;
set @ts1=now(6);
update t set a=22 where a=2;
select * from t for system_time all;
a
11
22
1
2
delete history from t before system_time timestamp @ts1;
select * from t for system_time all;
a
11
22
2
prepare stmt from 'delete history from t';
execute stmt;
drop prepare stmt;
select * from t for system_time all;
a
11
22
delete from t;
create or replace procedure truncate_sp()
begin
delete history from t before system_time timestamp now(6);
end~~
call truncate_sp;
select * from t for system_time all;
a
drop procedure truncate_sp;
# Truncate partitioned
create or replace table t (a int) with system versioning
partition by system_time limit 1 partitions 3;
insert into t values (1);
update t set a= 2;
update t set a= 3;
Warnings:
Warning	4114	Versioned table `test`.`t`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions
# You see warning above ^
delete history from t;
select * from t for system_time all;
a
3
# VIEW
create or replace table t (
i int,
row_start SYS_TYPE as row start invisible,
row_end SYS_TYPE as row end invisible,
period for system_time (row_start, row_end))
with system versioning;
delete history from t;
create or replace view v as select * from t;
delete history from v;
ERROR 42S02: 'v' is a view
create or replace table t (i int);
delete history from t;
ERROR HY000: Table `t` is not system-versioned
create or replace view v as select * from t;
delete history from v;
ERROR 42S02: 'v' is a view
prepare stmt from 'delete history from t';
ERROR HY000: Table `t` is not system-versioned
drop table t;
drop view v;
create or replace table t (i int);
create or replace view v as select * from t;
drop table v;
ERROR 42S02: 'test.v' is a view
lock table v write;
delete history from v before system_time now(6);
ERROR 42S02: 'v' is a view
unlock tables;
drop view v;
drop table t;
create table t1 (i int) with system versioning;
create procedure pr() delete history from t1 before system_time now();
call pr;
call pr;
drop procedure pr;
drop table t1;
# MDEV-15966 Behavior for TRUNCATE versioned table is not documented and not covered by tests
create or replace table t1 (id int);
create or replace table t2 (id int) with system versioning;
# force cleaning table shares
flush tables t1, t2;
truncate table t1;
truncate table t2;
ERROR HY000: System-versioned tables do not support TRUNCATE TABLE
# fetch table shares
describe t1;
Field	Type	Null	Key	Default	Extra
id	int(11)	YES		NULL	
describe t2;
Field	Type	Null	Key	Default	Extra
id	int(11)	YES		NULL	
truncate table t1;
truncate table t2;
ERROR HY000: System-versioned tables do not support TRUNCATE TABLE
# enter locked tables mode
lock tables t1 WRITE, t2 WRITE;
truncate t1;
truncate t2;
ERROR HY000: System-versioned tables do not support TRUNCATE TABLE
unlock tables;
drop table t2;
#
# MDEV-19814 Assertion `update->n_fields < ulint(table->n_cols + table->n_v_cols)' on DELETE HISTORY
#
create or replace table t1 (
f varchar(1),
row_start SYS_TYPE as row start,
row_end SYS_TYPE as row end,
period for system_time (row_start, row_end))
with system versioning;
insert into t1 (f) values ('a'), ('b'), ('c'), ('d'), ('e'), ('f'), ('g'), ('h');
delete from t1;
delete history from t1;
drop table t1;
#
# MDEV-20186 Wrong result or Assertion on INSERT after DELETE HISTORY
#
create or replace table t1 (a int check (a > 0)) with system versioning;
delete history from t1;
insert into t1 values (1);
select * from t1;
a
1
drop table t1;
#
# MDEV-25468 DELETE HISTORY may delete current data on system-versioned table
#
create or replace table t1 (x int) with system versioning;
insert into t1 values (1);
delete history from t1 before system_time '2039-01-01 23:00';
select * from t1;
x
1
explain extended delete history from t1 before system_time '2039-01-01 23:00';
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	1	100.00	Using where
Warnings:
Note	1003	delete  from `test`.`t1` FOR SYSTEM_TIME BEFORE TIMESTAMP '2039-01-01 23:00' using dual where `test`.`t1`.`row_end` < TIMESTAMP/*WITH LOCAL TIME ZONE*/'2039-01-01 23:00:00' and is_history(`test`.`t1`.`row_end`)
create or replace procedure p() delete history from t1 before system_time '2039-01-01 23:00';
call p;
select * from t1;
x
1
call p;
select * from t1;
x
1
drop procedure p;
prepare stmt from "delete history from t1 before system_time '2039-01-01 23:00'";
execute stmt;
select * from t1;
x
1
execute stmt;
select * from t1;
x
1
drop prepare stmt;
drop table t1;
#
# MDEV-25004 Missing row in FTS_DOC_ID_INDEX during DELETE HISTORY
#
create table t1 (a integer, c0 varchar(255), fulltext key (c0))
with system versioning engine innodb stats_persistent=0;
set system_versioning_alter_history= keep;
alter table t1 drop system versioning;
alter table t1 add system versioning;
insert into t1 values (1, 'politician');
update t1 set c0= 'criminal';
InnoDB		0 transactions not purged
delete history from t1;
drop table t1;
create table t1 (id int primary key, ftx varchar(255))
with system versioning engine innodb stats_persistent=0;
insert into t1 values (1, 'c');
delete from t1;
alter table t1 add fulltext key(ftx);
drop table t1;
#
# MDEV-28201 Server crashes upon SHOW ANALYZE/EXPLAIN FORMAT=JSON
#
CREATE TABLE t1 (a INT) WITH SYSTEM VERSIONING;
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
SET optimizer_trace= 'enabled=on';
DELETE HISTORY FROM v1 BEFORE SYSTEM_TIME '2021-01-01';
ERROR HY000: The target table v1 of the DELETE is not updatable
DELETE HISTORY FROM v1;
ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1;
DROP TABLE t1;
# End of 10.4 tests
#
# MDEV-33470 Unique hash index is broken on DML for system-versioned table
#
create or replace table t (
c int, unique (c) using hash)
with system versioning;
insert into t values (0);
delete from t;
delete history from t;
drop table t;
# End of 10.5 tests
#
# MDEV-17554 Auto-create new partition for system versioned tables with history partitioned by INTERVAL/LIMIT
#
# Don't auto-create new partition on DELETE HISTORY:
set timestamp= unix_timestamp('2000-01-01 00:00:00');
create or replace table t (a int) with system versioning
partition by system_time interval 1 hour auto;
set timestamp= unix_timestamp('2000-01-01 10:00:00');
delete history from t;
set timestamp= default;
show create table t;
Table	Create Table
t	CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL
) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci WITH SYSTEM VERSIONING
 PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR STARTS TIMESTAMP'2000-01-01 00:00:00' AUTO
PARTITIONS 2
drop table t;
# End of 10.9 tests
#
# MDEV-34046 Parameterized PS converts error to warning, causes replication problems
#
create table t (a int) with system versioning;
set timestamp= unix_timestamp('2000-01-01 00:00:00');
insert into t values (1), (100);
delete history from t before system_time @@timestamp;
ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME'
execute immediate "delete history from t before system_time @@timestamp";
ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME'
execute immediate "delete history from t before system_time ?" using @@timestamp;
ERROR HY000: Illegal parameter data type double for operation 'FOR SYSTEM_TIME'
set @ts1= '2000-01-01 00:00:01';
set timestamp= unix_timestamp(@ts1);
update t set a= a + 1 where a < 100;
set @ts2= '2000-01-01 00:00:02';
set timestamp= unix_timestamp(@ts2);
update t set a= a + 1 where a < 100;
set @ts3= '2000-01-01 00:00:03';
set timestamp= unix_timestamp(@ts3);
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
1	2000-01-01 00:00:00.000000	2000-01-01 00:00:01.000000
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
3	2000-01-01 00:00:02.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
select *, row_start, row_end from t for system_time as of @ts1;
a	row_start	row_end
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
execute immediate "select *, row_start, row_end from t for system_time as of ?" using @ts1;
a	row_start	row_end
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
prepare stmt from 'select *, row_start, row_end from t for system_time as of ?';
execute stmt using @ts1;
a	row_start	row_end
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
Execute stmt using @ts1;
a	row_start	row_end
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
select *, row_start, row_end from t for system_time as of @ts2;
a	row_start	row_end
3	2000-01-01 00:00:02.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute immediate "select *, row_start, row_end from t for system_time as of ?" using @ts2;
a	row_start	row_end
3	2000-01-01 00:00:02.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using @ts2;
a	row_start	row_end
3	2000-01-01 00:00:02.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
Execute stmt using @ts2;
a	row_start	row_end
3	2000-01-01 00:00:02.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
drop prepare stmt;
execute immediate "delete history from t before system_time @ts1";
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
1	2000-01-01 00:00:00.000000	2000-01-01 00:00:01.000000
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
3	2000-01-01 00:00:02.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute immediate "delete history from t before system_time @ts2";
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
3	2000-01-01 00:00:02.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute immediate "delete history from t before system_time ?" using @ts3;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
3	2000-01-01 00:00:02.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute immediate "delete history from t before system_time ?" using @ts3;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
3	2000-01-01 00:00:02.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
update t set a= a + 1 where a < 100;
set @ts4= '2000-01-01 00:00:04';
set timestamp= unix_timestamp(@ts4);
update t set a= a + 1 where a < 100;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
3	2000-01-01 00:00:02.000000	2000-01-01 00:00:03.000000
4	2000-01-01 00:00:03.000000	2000-01-01 00:00:04.000000
5	2000-01-01 00:00:04.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute immediate "delete history from t before system_time ?" using '2000-01-01 00:00:04';
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
4	2000-01-01 00:00:03.000000	2000-01-01 00:00:04.000000
5	2000-01-01 00:00:04.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
set @ts5= '2000-01-01 00:00:05';
set timestamp= unix_timestamp(@ts5);
update t set a= a + 1 where a < 100;
set @ts6= '2000-01-01 00:00:06';
set timestamp= unix_timestamp(@ts6);
update t set a= a + 1 where a < 100;
set @ts7= '2000-01-01 00:00:07';
set timestamp= unix_timestamp(@ts7);
update t set a= a + 1 where a < 100;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
4	2000-01-01 00:00:03.000000	2000-01-01 00:00:04.000000
5	2000-01-01 00:00:04.000000	2000-01-01 00:00:05.000000
6	2000-01-01 00:00:05.000000	2000-01-01 00:00:06.000000
7	2000-01-01 00:00:06.000000	2000-01-01 00:00:07.000000
8	2000-01-01 00:00:07.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
prepare stmt from 'delete history from t before system_time ?';
execute stmt using @ts4;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
4	2000-01-01 00:00:03.000000	2000-01-01 00:00:04.000000
5	2000-01-01 00:00:04.000000	2000-01-01 00:00:05.000000
6	2000-01-01 00:00:05.000000	2000-01-01 00:00:06.000000
7	2000-01-01 00:00:06.000000	2000-01-01 00:00:07.000000
8	2000-01-01 00:00:07.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using @ts5;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
5	2000-01-01 00:00:04.000000	2000-01-01 00:00:05.000000
6	2000-01-01 00:00:05.000000	2000-01-01 00:00:06.000000
7	2000-01-01 00:00:06.000000	2000-01-01 00:00:07.000000
8	2000-01-01 00:00:07.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using @ts6;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
6	2000-01-01 00:00:05.000000	2000-01-01 00:00:06.000000
7	2000-01-01 00:00:06.000000	2000-01-01 00:00:07.000000
8	2000-01-01 00:00:07.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using '2000-01-01 00:00:06';
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
6	2000-01-01 00:00:05.000000	2000-01-01 00:00:06.000000
7	2000-01-01 00:00:06.000000	2000-01-01 00:00:07.000000
8	2000-01-01 00:00:07.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using '2000-01-01 00:00:06.000001';
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
7	2000-01-01 00:00:06.000000	2000-01-01 00:00:07.000000
8	2000-01-01 00:00:07.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
set @ts8= '2000-01-01 00:00:08';
set timestamp= unix_timestamp(@ts8);
delete from t;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
7	2000-01-01 00:00:06.000000	2000-01-01 00:00:07.000000
8	2000-01-01 00:00:07.000000	2000-01-01 00:00:08.000000
100	2000-01-01 00:00:00.000000	2000-01-01 00:00:08.000000
execute immediate "delete history from t before system_time from_unixtime(?)" using @@timestamp;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
8	2000-01-01 00:00:07.000000	2000-01-01 00:00:08.000000
100	2000-01-01 00:00:00.000000	2000-01-01 00:00:08.000000
execute stmt using '2020-01-01';
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
drop prepare stmt;
set timestamp= unix_timestamp('2000-01-01 00:00:00');
insert into t values (1), (100);
set @ts1= '2000-01-01 00:00:01';
set timestamp= unix_timestamp(@ts1);
update t set a= a + 1 where a < 100;
set timestamp= @@timestamp + 1;
set @ts2= @@timestamp;
update t set a= a + 1 where a < 100;
set timestamp= @@timestamp + 1;
update t set a= a + 1 where a < 100;
prepare stmt from 'delete history from t before system_time from_unixtime(? + ?)';
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
1	2000-01-01 00:00:00.000000	2000-01-01 00:00:01.000000
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
3	2000-01-01 00:00:02.000000	2000-01-01 00:00:03.000000
4	2000-01-01 00:00:03.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using @ts1, 0;
Warnings:
Warning	1292	Truncated incorrect DOUBLE value: '2000-01-01 00:00:01'
Warning	1292	Truncated incorrect DOUBLE value: '2000-01-01 00:00:01'
Warning	1292	Truncated incorrect DOUBLE value: '2000-01-01 00:00:01'
Warning	1292	Truncated incorrect DOUBLE value: '2000-01-01 00:00:01'
Warning	1292	Truncated incorrect DOUBLE value: '2000-01-01 00:00:01'
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
1	2000-01-01 00:00:00.000000	2000-01-01 00:00:01.000000
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
3	2000-01-01 00:00:02.000000	2000-01-01 00:00:03.000000
4	2000-01-01 00:00:03.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using @ts2, 0;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
3	2000-01-01 00:00:02.000000	2000-01-01 00:00:03.000000
4	2000-01-01 00:00:03.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using @@timestamp, NULL;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
3	2000-01-01 00:00:02.000000	2000-01-01 00:00:03.000000
4	2000-01-01 00:00:03.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using NULL, NULL;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
2	2000-01-01 00:00:01.000000	2000-01-01 00:00:02.000000
3	2000-01-01 00:00:02.000000	2000-01-01 00:00:03.000000
4	2000-01-01 00:00:03.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using @ts2, 1;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
3	2000-01-01 00:00:02.000000	2000-01-01 00:00:03.000000
4	2000-01-01 00:00:03.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
execute stmt using @ts2, @ts2;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
4	2000-01-01 00:00:03.000000	2106-02-07 06:28:15.999999
100	2000-01-01 00:00:00.000000	2106-02-07 06:28:15.999999
delete from t;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
4	2000-01-01 00:00:03.000000	2000-01-01 00:00:03.000000
100	2000-01-01 00:00:00.000000	2000-01-01 00:00:03.000000
execute stmt using @ts2, @ts2;
select *, row_start, row_end from t for system_time all order by a;
a	row_start	row_end
drop prepare stmt;
drop table t;
set timestamp= default;
#
# MDEV-37164 Assertion `vers_conditions.delete_history' failed upon PREPARE
#
create table t (a int) with system versioning;
insert into t values (1),(2);
prepare stmt from 'select * from t for system_time as of timestamp ?';
drop table t;
# End of 10.11 tests