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
|
-- source include/have_partition.inc
-- source suite/versioning/common.inc
--echo # Check conventional partitioning on temporal tables
create table t1 (x int)
with system versioning
partition by range columns (x) (
partition p0 values less than (100),
partition p1 values less than (1000));
insert into t1 values (3), (300);
select * from t1;
select * from t1 partition (p0);
select * from t1 partition (p1);
delete from t1;
select * from t1;
select * from t1 for system_time all;
select * from t1 partition (p0);
select * from t1 partition (p1);
--echo # Engine change native <-> non-native versioning prohibited
--replace_result $default_engine DEFAULT_ENGINE
eval create or replace table t1 (i int) engine=$default_engine with system versioning partition by hash(i);
--replace_result $non_default_engine NON_DEFAULT_ENGINE
--error ER_VERS_ALTER_ENGINE_PROHIBITED
eval alter table t1 engine=$non_default_engine;
--echo ## CREATE TABLE
--error ER_VERS_ENGINE_UNSUPPORTED
create or replace table t1 (x int)
partition by system_time (
partition p0 history,
partition pn current);
create or replace table t1 (x int);
--error ER_VERS_ENGINE_UNSUPPORTED,ER_VERS_ENGINE_UNSUPPORTED
alter table t1
partition by system_time (
partition p0 history,
partition pn current);
--error ER_VERS_WRONG_PARTS
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 current);
--error ER_VERS_WRONG_PARTS
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 current,
partition p1 current);
--error ER_VERS_WRONG_PARTS
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 history,
partition p1 history);
--error ER_VERS_WRONG_PARTS
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition pn current,
partition p0 history);
--error ER_VERS_WRONG_PARTS
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0,
partition pn current);
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 history,
partition pn current);
--echo ## ALTER TABLE
--error ER_VERS_WRONG_PARTS
alter table t1 add partition (
partition p1 current);
alter table t1 add partition (
partition p1 history);
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
show create table t1;
insert into t1 values (1), (2);
--error ER_VERS_WRONG_PARTS
alter table t1 drop partition pn;
alter table t1 drop partition p1;
--error ER_VERS_WRONG_PARTS
alter table t1 drop partition p0;
select x from t1;
--echo # Bug #260: incorrect IB partitioning warning
create or replace table t1 (x int)
with system versioning
partition by system_time limit 1 (
partition p0 history,
partition pn current);
alter table t1 change x big int;
create or replace table t1 (i int) engine myisam partition by hash(i) partitions 2;
--error ER_PARTITION_WRONG_TYPE
alter table t1 add partition (partition px history);
--echo ## INSERT, UPDATE, DELETE
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 history,
partition pn current);
set @now= now(6);
insert into t1 values (1);
set @str= concat('select x, sys_trx_start < @now as A, sys_trx_end > @now as B from t1 partition (p0)');
prepare select_p0 from @str;
set @str= concat('select x, sys_trx_start > @now as C, sys_trx_end = timestamp\'2038-01-19 03:14:07.999999\' as D from t1 partition (pn)');
prepare select_pn from @str;
execute select_p0;
execute select_pn;
--echo ## pruning check
--replace_regex /\d/N/ /ALL/system/ /Using where//
explain partitions select * from t1;
set @str= concat('select sys_trx_start from t1 partition (pn) into @ts0');
prepare stmt from @str; execute stmt; drop prepare stmt;
set @now= now(6);
delete from t1;
execute select_p0;
execute select_pn;
set @str= concat('select sys_trx_start from t1 partition (p0) into @ts1');
prepare stmt from @str; execute stmt; drop prepare stmt;
select @ts0 = @ts1;
set @now= now(6);
insert into t1 values (2);
execute select_p0;
execute select_pn;
set @str= concat('select sys_trx_start from t1 partition (pn) into @ts0');
prepare stmt from @str; execute stmt; drop prepare stmt;
set @now= now(6);
update t1 set x = x + 1;
execute select_p0;
execute select_pn;
drop prepare select_p0;
drop prepare select_pn;
set @str= concat('select sys_trx_start from t1 partition (p0) where x = 2 into @ts1');
prepare stmt from @str; execute stmt; drop prepare stmt;
set @str= concat('select sys_trx_end from t1 partition (p0) where x = 2 into @ts2');
prepare stmt from @str; execute stmt; drop prepare stmt;
set @str= concat('select sys_trx_start from t1 partition (pn) into @ts3');
prepare stmt from @str; execute stmt; drop prepare stmt;
select @ts0 = @ts1;
select @ts2 = @ts3;
--echo ## rotation by LIMIT
--error ER_PART_WRONG_VALUE
create or replace table t1 (x int)
with system versioning
partition by system_time limit 0 (
partition p0 history,
partition p1 history,
partition pn current);
create or replace table t1 (x int)
with system versioning
partition by system_time limit 2 (
partition p0 history,
partition p1 history,
partition pn current);
--replace_result $default_engine DEFAULT_ENGINE $sys_datatype SYS_DATATYPE
show create table t1;
--error ER_DROP_PARTITION_NON_EXISTENT
alter table t1 drop partition non_existent;
insert into t1 values (1), (2), (3);
select * from t1 partition (pn);
--echo ### warn about partition switching
delete from t1;
select * from t1 partition (p0);
select * from t1 partition (p1);
insert into t1 values (4), (5);
--echo ### warn about full partition
delete from t1;
select * from t1 partition (p1) order by x;
--echo ## rotation by INTERVAL
--error ER_PART_WRONG_VALUE
create or replace table t1 (x int)
with system versioning
partition by system_time interval 0 second (
partition p0 history,
partition p1 history,
partition pn current);
create or replace table t1 (x int)
with system versioning
partition by system_time interval 1 second (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 values (1), (2), (3);
select * from t1 partition (pn);
delete from t1;
select * from t1 partition (p0);
--sleep 2
insert into t1 values (4);
delete from t1;
select * from t1 partition (p1);
--echo ## Subpartitions
create or replace table t1 (x int)
with system versioning
partition by system_time limit 2
subpartition by key (x)
subpartitions 2 (
partition p0 history,
partition p1 history,
partition pn current);
insert into t1 (x) values (1), (2), (3), (4), (5);
select * from t1 partition (pnsp0);
select * from t1 partition (pnsp1);
--echo ### warn about partition switching and about full partition
delete from t1;
select * from t1 partition (p0sp0);
select * from t1 partition (p0sp1);
select * from t1 partition (p1sp0);
select * from t1 partition (p1sp1);
create or replace table t1 (a bigint)
with system versioning
partition by range (a)
(partition p0 values less than (20) engine innodb,
partition p1 values less than maxvalue engine innodb);
insert into t1 values (1);
create or replace table t1 (
f_int1 integer default 0
) with system versioning
partition by range(f_int1)
subpartition by hash(f_int1)
( partition part1 values less than (1000)
(subpartition subpart11 storage engine = 'innodb',
subpartition subpart12 storage engine = 'innodb'));
insert into t1 values (1);
create or replace table t1 (i int) engine=innodb partition by key(i);
alter table t1 add system versioning;
insert into t1 values();
drop table t1;
-- source suite/versioning/common_finish.inc
|