You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lots of changes: * calculate the current history partition in ::external_lock(), not in ::write_row() or ::update_row() * remove dynamically collected per-partition row_end stats * no full table scan in open_table_from_share to calculate these stats, no manual MDL/thr_locks in open_table_from_share * no shared stats in TABLE_SHARE = no mutexes or condition waits when calculating current history partition * always compare timestamps, don't convert them to MYSQL_TIME (avoid DST ambiguity, and it's faster too) * correct interval handling, 1 month = 1 month, not 30 * 24 * 3600 seconds * save/restore first partition start time, and count intervals from there * only allow to drop first partitions if INTERVAL * when adding new history partitions, split the data in the last history parition, if it was overflowed * show partition boundaries in INFORMATION_SCHEMA.PARTITIONS
id select_type table partitions type possible_keys key key_len ref rows Extra
143
-
N SIMPLE tN pN,pn system NULL NULL NULL NULL N
144
140
set @str= concat('select row_start from t1 partition (pn) into @ts0');
145
141
prepare stmt from @str;
146
142
execute stmt;
@@ -225,42 +221,48 @@ t1 CREATE TABLE `t1` (
225
221
PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE)
226
222
alter table t1 drop partition non_existent;
227
223
ERROR HY000: Error in list of partitions to DROP
228
-
insert into t1 values (1), (2), (3);
224
+
insert into t1 values (1), (2), (3), (4), (5), (6);
229
225
select * from t1 partition (pn);
230
226
x
231
227
1
232
228
2
233
229
3
234
-
### warn about partition switching
230
+
4
231
+
5
232
+
6
233
+
delete from t1 where x < 4;
235
234
delete from t1;
236
-
Warnings:
237
-
Note 4114 Versioned table `test`.`t1`: switching from partition `p0` to `p1`
238
235
select * from t1 partition (p0);
239
236
x
240
237
1
241
238
2
239
+
3
242
240
select * from t1 partition (p1);
243
241
x
244
-
3
245
-
insert into t1 values (4), (5);
242
+
4
243
+
5
244
+
6
245
+
insert into t1 values (7), (8);
246
+
Warnings:
247
+
Warning 4112 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
246
248
### warn about full partition
247
249
delete from t1;
248
250
Warnings:
249
251
Warning 4112 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
250
252
select * from t1 partition (p1) order by x;
251
253
x
252
-
3
253
254
4
254
255
5
256
+
6
257
+
7
258
+
8
255
259
### Assertion in ALTER on warning from partitioning LIMIT [#446]
256
260
create or replace table t1 (x int) with system versioning;
257
261
insert into t1 values (1), (2);
258
262
delete from t1;
259
263
alter table t1 partition by system_time limit 1 (
260
264
partition p1 history,
261
265
partition pn current);
262
-
Warnings:
263
-
Note 4112 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
264
266
## rotation by INTERVAL
265
267
create or replace table t1 (x int)
266
268
with system versioning
@@ -269,6 +271,16 @@ partition p0 history,
269
271
partition p1 history,
270
272
partition pn current);
271
273
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
274
+
create or replace table t1 (x int)
275
+
with system versioning
276
+
partition by system_time interval 1 second starts 12345 (
277
+
partition p0 history,
278
+
partition p1 history,
279
+
partition pn current);
280
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'starts 12345 (
281
+
partition p0 history,
282
+
partition p1 history,
283
+
partition pn current)' at line 3
272
284
### ha_partition::update_row() check
273
285
create or replace table t1 (x int)
274
286
with system versioning
@@ -286,7 +298,7 @@ x
286
298
delete from t1 where x < 3;
287
299
delete from t1;
288
300
Warnings:
289
-
Note 4114Versioned table `test`.`t1`: switching from partition `p0` to `p1`
301
+
Warning 4112Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
290
302
select * from t1 partition (p0) order by x;
291
303
x
292
304
1
@@ -306,7 +318,7 @@ insert into t1 values (1);
306
318
update t1 set x= 2;
307
319
update t1 set x= 3;
308
320
Warnings:
309
-
Note 4114Versioned table `test`.`t1`: switching from partition `p0` to `p1`
321
+
Warning 4112Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
310
322
select * from t1 partition (p0);
311
323
x
312
324
1
@@ -332,24 +344,23 @@ select * from t1 partition (pnsp1);
332
344
x
333
345
2
334
346
4
335
-
### warn about partition switching and about full partition
347
+
### warn about full partition
348
+
delete from t1 where x < 3;
349
+
delete from t1;
336
350
delete from t1;
337
-
Warnings:
338
-
Note 4114 Versioned table `test`.`t1`: switching from partition `p0` to `p1`
339
-
Warning 4112 Versioned table `test`.`t1`: partition `p1` is full, add more HISTORY partitions
340
351
select * from t1 partition (p0sp0);
341
352
x
342
353
1
343
354
3
355
+
5
344
356
select * from t1 partition (p0sp1);
345
357
x
358
+
2
359
+
4
346
360
select * from t1 partition (p1sp0);
347
361
x
348
-
5
349
362
select * from t1 partition (p1sp1);
350
363
x
351
-
2
352
-
4
353
364
create or replace table t1 (a bigint)
354
365
with system versioning
355
366
partition by range (a)
@@ -419,14 +430,8 @@ alter table t1 partition by system_time limit 1 (
419
430
partition p1 history,
420
431
partition p2 history,
421
432
partition pn current);
422
-
Warnings:
423
-
Note 4114 Versioned table `test`.`t1`: switching from partition `p1` to `p2`
424
433
delete from t1 where x = 1;
425
-
Warnings:
426
-
Warning 4112 Versioned table `test`.`t1`: partition `p2` is full, add more HISTORY partitions
427
434
delete from t1 where x = 2;
428
-
Warnings:
429
-
Warning 4112 Versioned table `test`.`t1`: partition `p2` is full, add more HISTORY partitions
430
435
# MDEV-14923 Assertion upon INSERT into locked versioned partitioned table
431
436
create or replace table t1 (x int) with system versioning
432
437
partition by system_time (partition p1 history, partition pn current);
create or replace table t1 (pk int) with system versioning
444
+
partition by system_time interval 10 year (
445
+
partition p1 history,
446
+
partition p2 history,
447
+
partition pn current
448
+
);
449
+
ERROR 22003: TIMESTAMP value is out of range in 'INTERVAL'
450
+
create or replace table t1 (i int) with system versioning
451
+
partition by system_time interval 1 hour (
452
+
partition p0 history, partition pn current);
453
+
set @ts=(select partition_description from information_schema.partitions
454
+
where table_schema='test' and table_name='t1' and partition_name='p0');
455
+
alter table t1 add column b int;
456
+
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
Warning 1292 Truncated incorrect time value: 'CURRENT'
471
+
alter table t1 drop partition p0;
472
+
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
Warning 1292 Truncated incorrect time value: 'CURRENT'
479
+
alter table t1 drop partition p2;
480
+
ERROR HY000: Can only drop oldest partitions when rotating by INTERVAL
481
+
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
create or replace table t1 (pk int) with system versioning
395
+
partition by system_time interval 10 year (
396
+
partition p1 history,
397
+
partition p2 history,
398
+
partition pn current
399
+
);
400
+
401
+
# INTERVAL and ALTER TABLE
402
+
create or replace table t1 (i int) with system versioning
403
+
partition by system_time interval 1 hour (
404
+
partition p0 history, partition pn current);
405
+
406
+
set @ts=(select partition_description from information_schema.partitions
407
+
where table_schema='test' and table_name='t1' and partition_name='p0');
408
+
409
+
alter table t1 add column b int;
410
+
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
413
+
alter table t1 drop partition p0;
414
+
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
415
+
--error ER_VERS_DROP_PARTITION_INTERVAL
416
+
alter table t1 drop partition p2;
417
+
select partition_name,partition_ordinal_position,partition_method,timediff(partition_description, @ts) from information_schema.partitions where table_schema='test' and table_name='t1';
418
+
419
+
create or replace table t1 (i int) with system versioning
0 commit comments