summaryrefslogtreecommitdiff
path: root/mysql-test/suite/versioning/r/create.result
blob: f3ea50192ce602720a91396162d91032462df1bf (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
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
set @@session.time_zone='+00:00';
select ifnull(max(trx_id), 0) into @start_trx_id from information_schema.innodb_vtq;
create procedure if not exists verify_vtq()
begin
set @i= 0;
select
@i:= @i + 1 as No,
trx_id > 0 as A,
commit_id > trx_id as B,
begin_ts > '1-1-1 0:0:0' as C,
commit_ts >= begin_ts as D
from information_schema.innodb_vtq
where trx_id > @start_trx_id;
select ifnull(max(trx_id), 0)
into @start_trx_id
from information_schema.innodb_vtq;
end~~
create function if not exists default_engine()
returns varchar(255)
deterministic
begin
declare e varchar(255);
select lower(engine) from information_schema.engines where support='DEFAULT' into e;
return e;
end~~
create function if not exists sys_datatype()
returns varchar(255)
deterministic
begin
if default_engine() = 'innodb' then
return 'bigint unsigned';
elseif default_engine() = 'myisam' then
return 'timestamp(6)';
end if;
return NULL;
end~~
create function if not exists sys_commit_ts(sys_field varchar(255))
returns varchar(255)
deterministic
begin
if default_engine() = 'innodb' then
return concat('vtq_commit_ts(', sys_field, ')');
elseif default_engine() = 'myisam' then
return sys_field;
end if;
return NULL;
end~~
create procedure if not exists innodb_verify_vtq(recs int)
begin
declare i int default 1;
if default_engine() = 'innodb' then
call verify_vtq;
elseif default_engine() = 'myisam' then
create temporary table tmp (No int, A bool, B bool, C bool, D bool);
while i <= recs do
insert into tmp values (i, 1, 1, 1, 1);
set i= i + 1;
end while;
select * from tmp;
drop table tmp;
end if;
end~~
drop table if exists t1;
create function if not exists non_default_engine()
returns varchar(255)
deterministic
begin
if default_engine() = 'innodb' then
return 'myisam';
end if;
return 'innodb';
end~~
create table t1 (
x1 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start comment 'start',
Sys_end SYS_TRX_TYPE generated always as row end comment 'end',
period for system_time (Sys_start, Sys_end)
) with system versioning;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `x1` int(10) unsigned DEFAULT NULL,
  `Sys_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START COMMENT 'start',
  `Sys_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END COMMENT 'end',
  PERIOD FOR SYSTEM_TIME (`Sys_start`, `Sys_end`)
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
# Implicit fields test
create or replace table t1 (
x2 int unsigned
) with system versioning;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `x2` int(10) unsigned DEFAULT NULL,
  `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
  `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
  PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
x3 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_start2 SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW START'
create or replace table t1 (
x4 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end2 SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW END' mismatch
create or replace table t1 (
x5 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
Sys_end2 SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW END'
create or replace table t1 (
x6 int unsigned,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: 'GENERATED AS ROW START' column missing
create or replace table t1 (
x7 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
Sys_end2 SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW END'
create or replace table t1 (
x8 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
period for system_time (sys_insert, sys_remove)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW START' mismatch
create or replace table t1 (
x9 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
create or replace table t1 (
x10 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_start)
);
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' columns must be different
create or replace table t1 (
x11 int unsigned,
Sys_start bigint unsigned generated always as row start,
Sys_end timestamp(6) generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
Got one of the listed errors
create or replace table t1 (
x12 int unsigned,
Sys_start timestamp(6) generated always as row start,
Sys_end bigint unsigned generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
Got one of the listed errors
create or replace table t1 (
x13 int unsigned,
Sys_start bigint generated always as row start,
Sys_end bigint unsigned generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
ERROR HY000: `Sys_start` must be of type `BIGINT(20) UNSIGNED` for versioned table `t1`
create or replace table t1 (
x14 int unsigned,
Sys_start bigint unsigned generated always as row start,
Sys_end bigint generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning engine innodb;
ERROR HY000: `Sys_end` must be of type `BIGINT(20) UNSIGNED` for versioned table `t1`
create or replace table t1 (
A1 int with system versioning,
B int
);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `A1` int(11) DEFAULT NULL,
  `B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
  `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
  `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
  PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
A2 int with system versioning,
B int
) with system versioning;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `A2` int(11) DEFAULT NULL,
  `B` int(11) DEFAULT NULL,
  `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
  `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
  PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
A3 int,
B int without system versioning
);
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
create or replace table t1 (
A4 int,
B int without system versioning
) with system versioning;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `A4` int(11) DEFAULT NULL,
  `B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
  `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
  `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
  PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
A5 int with system versioning,
B int without system versioning
);
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `A5` int(11) DEFAULT NULL,
  `B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
  `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
  `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
  PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
A6 int with system versioning,
B int without system versioning
) with system versioning;
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `A6` int(11) DEFAULT NULL,
  `B` int(11) DEFAULT NULL WITHOUT SYSTEM VERSIONING,
  `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
  `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
  PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t1 (
A7 int without system versioning
);
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
create or replace table t1 (
A8 int without system versioning
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: no columns defined with system versioning!
create or replace table t1 (
A9 int without system versioning with system versioning
);
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same field
create or replace table t1 (
A10 int with system versioning without system versioning
);
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same field
create table t(
a11 int
) without system versioning;
ERROR HY000: Wrong parameters for `t`: 'WITHOUT SYSTEM VERSIONING' is not allowed
create or replace table t1 (
A12 int
) without system versioning with system versioning;
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
create or replace table t1 (
A13 int
) with system versioning without system versioning;
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
create or replace table t1 (
A14 int
) with system versioning with system versioning;
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
create or replace table t1 (
A15 int
) without system versioning without system versioning;
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
create or replace table t1 (a int) with system versioning;
create temporary table tmp with system versioning select * from t1;
create or replace table t1 (a int) with system versioning;
create table tt1 like t1;
show create table tt1;
Table	Create Table
tt1	CREATE TABLE `tt1` (
  `a` int(11) DEFAULT NULL,
  `sys_trx_start` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
  `sys_trx_end` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
  PERIOD FOR SYSTEM_TIME (`sys_trx_start`, `sys_trx_end`)
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
drop table tt1;
create or replace table t1 (x int) with system versioning;
create or replace table t2 (y int);
create or replace table t3 select * from t1 for system_time all, t2;
show create table t3;
Table	Create Table
t3	CREATE TABLE `t3` (
  `x` int(11) DEFAULT NULL,
  `y` int(11) DEFAULT NULL
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1
create or replace table t2 (
y int,
st SYS_TRX_TYPE generated always as row start,
en SYS_TRX_TYPE generated always as row end,
period for system_time (st, en)
) with system versioning;
create or replace table t3 select * from t2;
show create table t3;
Table	Create Table
t3	CREATE TABLE `t3` (
  `y` int(11) DEFAULT NULL,
  `st` SYS_TRX_TYPE GENERATED ALWAYS AS ROW START,
  `en` SYS_TRX_TYPE GENERATED ALWAYS AS ROW END,
  PERIOD FOR SYSTEM_TIME (`st`, `en`)
) ENGINE=INNODB_OR_MYISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
create or replace table t3 select x, y, t1.sys_trx_start, t2.en from t1, t2;
ERROR HY000: Wrong parameters for `t3`: system fields selected from different tables
insert into t2 values (1), (2);
delete from t2 where y = 2;
create or replace table t3 select * from t2 for system_time all;
select st, en from t2 where y = 1 into @st, @en;
select y from t2 for system_time all where st = @st and en = @en;
y
1
select st, en from t2 for system_time all where y = 2 into @st, @en;
select y from t2 for system_time all where st = @st and en = @en;
y
2
create or replace table t1 (a int) with system versioning engine INNODB_OR_MYISAM;
create or replace table t2 as select a, sys_trx_start, sys_trx_end from t1 for system_time all;
create or replace table t2 engine INNODB_OR_MYISAM as select a, sys_trx_start, sys_trx_end from t1 for system_time all;
ERROR HY000: `sys_trx_start` must be of type `SYS_TRX_TYPE` for versioned table `t2`
create or replace table t1 (a int, id int) with system versioning engine INNODB_OR_MYISAM;
create or replace table t2 (b int, id int);
create or replace table t3 as
select t2.b, t1.a, t1.sys_trx_start, t1.sys_trx_end from t2 inner join t1 on t2.id=t1.id;
drop table t1;
drop table t2;
drop table t3;
drop function non_default_engine;
drop procedure verify_vtq;
drop procedure innodb_verify_vtq;
drop function default_engine;
drop function sys_commit_ts;
drop function sys_datatype;