File: insert2.test

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 (94 lines) | stat: -rw-r--r-- 2,888 bytes parent folder | download | duplicates (2)
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
--source include/have_innodb.inc
set @@time_zone='+00:00';
--source suite/versioning/sys_time.inc

# TRT test

create table t1(
  x int unsigned,
  sys_start bigint unsigned as row start invisible,
  sys_end bigint unsigned as row end invisible,
  period for system_time (sys_start, sys_end))
with system versioning engine=innodb;

create table t2(x int unsigned) engine=innodb;

start transaction;
insert into t1(x) values(1);
commit;

start transaction;
insert into t2(x) values(1);
savepoint a;
insert into t1(x) values(1);
rollback to a;
commit;

insert into t2(x) values (1);

# virtual columns
create or replace table t1 (
  x int,
  y int as (x) virtual,
  sys_trx_start bigint unsigned as row start invisible,
  sys_trx_end bigint unsigned as row end invisible,
  period for system_time (sys_trx_start, sys_trx_end)
) engine=innodb with system versioning;
insert into t1 values (1, null);
update t1 set x= x + 1;
select x, y, sys_trx_end = 18446744073709551615 as current from t1 for system_time all;

create or replace table t1 (
  x int,
  row_start timestamp(6) as row start invisible,
  row_end timestamp(6) as row end invisible,
  period for system_time (row_start, row_end)
) with system versioning;
insert into t1 values  (1), (2);
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
insert into t1 (row_start) select row_end from t1;
set sql_mode='';
insert into t1 (row_start, row_end) values (DEFAULT, 1);
set sql_mode=default;
--disable_cursor_protocol
select @@sql_mode into @saved_mode;
--enable_cursor_protocol
set sql_mode= '';
insert into t1 (x, row_start, row_end) values (3, 4, 5);
set sql_mode= @saved_mode;
insert into t1 (row_start, row_end) values (DEFAULT, DEFAULT);
select * from t1;

--echo # MDEV-14792 INSERT without column list into table with explicit versioning columns produces bad data
create or replace table t1 (
  i int,
  s timestamp(6) as row start,
  e timestamp(6) as row end,
  c varchar(8),
  period for system_time(s, e))
with system versioning;
insert into t1 values (1, null, null, 'foo');
--replace_result $sys_time_max SYS_TIME_MAX
--eval select i, c,  e>LEFT($sys_time_max, 10) AS current_row from t1;

drop table t1;
drop table t2;

--echo #
--echo # MDEV-14871 Server crashes in fill_record / fill_record_n_invoke_before_triggers upon inserting into versioned table with trigger
--echo #
create or replace table t1 (pk int primary key) with system versioning;
create trigger tr before insert on t1 for each row select 1 into @a;
insert into t1 values (1),(2);
drop table t1;

#
# MDEV-14794 Limitations which the row end as a part of PK imposes due to CURRENT_TIMESTAMP behavior and otherwise
#
create table t1 (pk int primary key, i int) with system versioning;
replace into t1 values (1,10),(1,100),(1,1000);
select pk,i,row_end > '2038-01-01' from t1 for system_time all;
drop table t1;

# Cleanup
set @@time_zone=default;