summaryrefslogtreecommitdiff
path: root/mysql-test/suite/versioning/t/sysvars.test
blob: 52fab81b8e6581f7c269257695beafc18620c096 (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
create table t (a int) with system versioning;
insert into t values (1);
update t set a= 2;

show global variables like 'system_versioning_asof';
show variables like 'system_versioning_asof';
select * from t;

set system_versioning_asof= '2031-1-1 0:0:0';
show variables like 'system_versioning_asof';
select * from t;

set system_versioning_asof= '2011-1-1 0:0:0';
show variables like 'system_versioning_asof';
select * from t;

# global
--error ER_WRONG_VALUE_FOR_VAR
set global system_versioning_asof= 'alley';
--error ER_WRONG_VALUE_FOR_VAR
set global system_versioning_asof= null;
--error ER_WRONG_TYPE_FOR_VAR
set global system_versioning_asof= 1;
--error ER_WRONG_TYPE_FOR_VAR
set global system_versioning_asof= 1.1;

# session
--error ER_WRONG_VALUE_FOR_VAR
set system_versioning_asof= 'alley';
--error ER_WRONG_VALUE_FOR_VAR
set system_versioning_asof= null;
--error ER_WRONG_TYPE_FOR_VAR
set system_versioning_asof= 1;
--error ER_WRONG_TYPE_FOR_VAR
set system_versioning_asof= 1.1;

--echo # GLOBAL @@system_versioning_asof
set global system_versioning_asof= '1911-11-11 11:11:11.1111119';
show global variables like 'system_versioning_asof';

set global system_versioning_asof= '1900-01-01 00:00:00';
show global variables like 'system_versioning_asof';

set global system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
show global variables like 'system_versioning_asof';

set @ts= timestamp'1900-01-01 00:00:00';
set global system_versioning_asof= @ts;
show global variables like 'system_versioning_asof';

set global system_versioning_asof= default;
select @@global.system_versioning_asof;

--echo # SESSION @@system_versioning_asof
set system_versioning_asof= '1911-11-11 11:11:11.1111119';
show variables like 'system_versioning_asof';

set system_versioning_asof= '1900-01-01 00:00:00';
show variables like 'system_versioning_asof';

set system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119';
show variables like 'system_versioning_asof';

set @ts= timestamp'1900-01-01 00:00:00';
set system_versioning_asof= @ts;
show variables like 'system_versioning_asof';

--echo # DEFAULT: value is copied from GLOBAL to SESSION
set global system_versioning_asof= timestamp'1911-11-11 11:11:11.111111';
set system_versioning_asof= '1900-01-01 00:00:00';
select @@global.system_versioning_asof != @@system_versioning_asof as different;
set system_versioning_asof= default;
select @@global.system_versioning_asof = @@system_versioning_asof as equal;

set global system_versioning_asof= DEFAULT;
set system_versioning_asof= DEFAULT;
select @@global.system_versioning_asof, @@system_versioning_asof;

select * from t for system_time all;

select * from t;
select * from t for system_time as of timestamp current_timestamp(6);
select * from t for system_time all;
select * from t for system_time from '0-0-0' to current_timestamp(6);
select * from t for system_time between '0-0-0' and current_timestamp(6);

show status like "Feature_system_versioning";

drop table t;


--echo #
--echo # MDEV-16991 Rounding vs truncation for TIME, DATETIME, TIMESTAMP
--echo #

SET sql_mode=TIME_ROUND_FRACTIONAL;
SET @@global.system_versioning_asof= timestamp'2001-12-31 23:59:59.9999999';
SELECT @@global.system_versioning_asof;
SET @@global.system_versioning_asof= DEFAULT;