@@ -224,13 +224,13 @@ SELECT create_range_partitions('subpartitions.abc', 'a', 0, 100, 2);
224
224
2
225
225
(1 row)
226
226
227
- SELECT create_range_partitions('subpartitions.abc_1', 'b', 0, 50, 2);
227
+ SELECT create_range_partitions('subpartitions.abc_1', 'b', 0, 50, 2); /* 0 - 100 */
228
228
create_range_partitions
229
229
-------------------------
230
230
2
231
231
(1 row)
232
232
233
- SELECT create_range_partitions('subpartitions.abc_2', 'b', 0, 50, 2);
233
+ SELECT create_range_partitions('subpartitions.abc_2', 'b', 0, 50, 2); /* 100 - 200 */
234
234
create_range_partitions
235
235
-------------------------
236
236
2
@@ -324,7 +324,7 @@ SELECT subpartitions.partitions_tree('subpartitions.abc');
324
324
(9 rows)
325
325
326
326
/* merge_range_partitions */
327
- SELECT append_range_partition('subpartitions.abc', 'subpartitions.abc_3');
327
+ SELECT append_range_partition('subpartitions.abc', 'subpartitions.abc_3'); /* 200 - 300 */
328
328
append_range_partition
329
329
------------------------
330
330
subpartitions.abc_3
@@ -340,6 +340,149 @@ select merge_range_partitions('subpartitions.abc_2_1', 'subpartitions.abc_2_2');
340
340
341
341
DROP TABLE subpartitions.abc CASCADE;
342
342
NOTICE: drop cascades to 11 other objects
343
+ /* subpartitions on same expressions */
344
+ CREATE TABLE subpartitions.abc(a INTEGER NOT NULL);
345
+ INSERT INTO subpartitions.abc SELECT i FROM generate_series(1, 200, 20) as i;
346
+ SELECT create_range_partitions('subpartitions.abc', 'a', 0, 100, 4);
347
+ create_range_partitions
348
+ -------------------------
349
+ 4
350
+ (1 row)
351
+
352
+ SELECT create_range_partitions('subpartitions.abc_1', 'a', 0, 11, 9); /* not multiple */
353
+ create_range_partitions
354
+ -------------------------
355
+ 9
356
+ (1 row)
357
+
358
+ SELECT create_range_partitions('subpartitions.abc_2', 'a', 150, 11, 8); /* start_value should be lower */
359
+ WARNING: "start_value" was set to 100
360
+ create_range_partitions
361
+ -------------------------
362
+ 8
363
+ (1 row)
364
+
365
+ SELECT create_range_partitions('subpartitions.abc_3', 'a', 200, 11, 20); /* too big p_count */
366
+ WARNING: "p_interval" is not multiple of range (200, 310)
367
+ NOTICE: "p_count" was limited to 10
368
+ create_range_partitions
369
+ -------------------------
370
+ 10
371
+ (1 row)
372
+
373
+ SELECT create_range_partitions('subpartitions.abc_4', 'a', ARRAY[301, 350, 400]); /* bounds check */
374
+ ERROR: Bounds should start from 300
375
+ SELECT create_range_partitions('subpartitions.abc_4', 'a', ARRAY[300, 450, 500]); /* bounds check */
376
+ ERROR: Lower bound of rightmost partition should be less than 400
377
+ SELECT create_range_partitions('subpartitions.abc_4', 'a', ARRAY[300, 350, 450]); /* bounds check */
378
+ create_range_partitions
379
+ -------------------------
380
+ 2
381
+ (1 row)
382
+
383
+ \d+ subpartitions.abc_1
384
+ Table "subpartitions.abc_1"
385
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
386
+ --------+---------+-----------+----------+---------+---------+--------------+-------------
387
+ a | integer | | not null | | plain | |
388
+ Check constraints:
389
+ "pathman_abc_1_check" CHECK (a >= 0 AND a < 100)
390
+ Inherits: subpartitions.abc
391
+ Child tables: subpartitions.abc_1_1,
392
+ subpartitions.abc_1_2,
393
+ subpartitions.abc_1_3,
394
+ subpartitions.abc_1_4,
395
+ subpartitions.abc_1_5,
396
+ subpartitions.abc_1_6,
397
+ subpartitions.abc_1_7,
398
+ subpartitions.abc_1_8,
399
+ subpartitions.abc_1_9
400
+
401
+ SELECT * FROM pathman_partition_list;
402
+ parent | partition | parttype | expr | range_min | range_max
403
+ ---------------------+------------------------+----------+------+-----------+-----------
404
+ subpartitions.abc | subpartitions.abc_1 | 2 | a | 0 | 100
405
+ subpartitions.abc | subpartitions.abc_2 | 2 | a | 100 | 200
406
+ subpartitions.abc | subpartitions.abc_3 | 2 | a | 200 | 300
407
+ subpartitions.abc | subpartitions.abc_4 | 2 | a | 300 | 400
408
+ subpartitions.abc_1 | subpartitions.abc_1_1 | 2 | a | 0 | 11
409
+ subpartitions.abc_1 | subpartitions.abc_1_2 | 2 | a | 11 | 22
410
+ subpartitions.abc_1 | subpartitions.abc_1_3 | 2 | a | 22 | 33
411
+ subpartitions.abc_1 | subpartitions.abc_1_4 | 2 | a | 33 | 44
412
+ subpartitions.abc_1 | subpartitions.abc_1_5 | 2 | a | 44 | 55
413
+ subpartitions.abc_1 | subpartitions.abc_1_6 | 2 | a | 55 | 66
414
+ subpartitions.abc_1 | subpartitions.abc_1_7 | 2 | a | 66 | 77
415
+ subpartitions.abc_1 | subpartitions.abc_1_8 | 2 | a | 77 | 88
416
+ subpartitions.abc_1 | subpartitions.abc_1_9 | 2 | a | 88 | 99
417
+ subpartitions.abc_2 | subpartitions.abc_2_1 | 2 | a | 100 | 111
418
+ subpartitions.abc_2 | subpartitions.abc_2_2 | 2 | a | 111 | 122
419
+ subpartitions.abc_2 | subpartitions.abc_2_3 | 2 | a | 122 | 133
420
+ subpartitions.abc_2 | subpartitions.abc_2_4 | 2 | a | 133 | 144
421
+ subpartitions.abc_2 | subpartitions.abc_2_5 | 2 | a | 144 | 155
422
+ subpartitions.abc_2 | subpartitions.abc_2_6 | 2 | a | 155 | 166
423
+ subpartitions.abc_2 | subpartitions.abc_2_7 | 2 | a | 166 | 177
424
+ subpartitions.abc_2 | subpartitions.abc_2_8 | 2 | a | 177 | 188
425
+ subpartitions.abc_3 | subpartitions.abc_3_1 | 2 | a | 200 | 211
426
+ subpartitions.abc_3 | subpartitions.abc_3_2 | 2 | a | 211 | 222
427
+ subpartitions.abc_3 | subpartitions.abc_3_3 | 2 | a | 222 | 233
428
+ subpartitions.abc_3 | subpartitions.abc_3_4 | 2 | a | 233 | 244
429
+ subpartitions.abc_3 | subpartitions.abc_3_5 | 2 | a | 244 | 255
430
+ subpartitions.abc_3 | subpartitions.abc_3_6 | 2 | a | 255 | 266
431
+ subpartitions.abc_3 | subpartitions.abc_3_7 | 2 | a | 266 | 277
432
+ subpartitions.abc_3 | subpartitions.abc_3_8 | 2 | a | 277 | 288
433
+ subpartitions.abc_3 | subpartitions.abc_3_9 | 2 | a | 288 | 299
434
+ subpartitions.abc_3 | subpartitions.abc_3_10 | 2 | a | 299 | 310
435
+ subpartitions.abc_4 | subpartitions.abc_4_1 | 2 | a | 300 | 350
436
+ subpartitions.abc_4 | subpartitions.abc_4_2 | 2 | a | 350 | 450
437
+ (33 rows)
438
+
439
+ SELECT append_range_partition('subpartitions.abc_1'::regclass);
440
+ append_range_partition
441
+ ------------------------
442
+ subpartitions.abc_1_10
443
+ (1 row)
444
+
445
+ SELECT append_range_partition('subpartitions.abc_1'::regclass);
446
+ ERROR: reached upper bound in the current level of subpartitions
447
+ DROP TABLE subpartitions.abc_1_10;
448
+ /* detach_range_partition */
449
+ SELECt detach_range_partition('subpartitions.abc_1');
450
+ ERROR: could not detach partition if it has children
451
+ /* attach_range_partition */
452
+ CREATE TABLE subpartitions.abc_c(LIKE subpartitions.abc_1 INCLUDING ALL);
453
+ SELECT attach_range_partition('subpartitions.abc_1', 'subpartitions.abc_c', 98, 110); /* fail */
454
+ ERROR: specified range [98, 110) overlaps with existing partitions
455
+ SELECT attach_range_partition('subpartitions.abc_1', 'subpartitions.abc_c', 100, 110); /* fail */
456
+ ERROR: "start value" exceeds upper bound of the current level of subpartitions
457
+ SELECT attach_range_partition('subpartitions.abc_1', 'subpartitions.abc_c', 99, 110); /* ok */
458
+ attach_range_partition
459
+ ------------------------
460
+ subpartitions.abc_c
461
+ (1 row)
462
+
463
+ DROP TABLE subpartitions.abc CASCADE;
464
+ NOTICE: drop cascades to 39 other objects
465
+ /* subpartitions on same expression but dates */
466
+ CREATE TABLE subpartitions.abc(a DATE NOT NULL);
467
+ INSERT INTO subpartitions.abc SELECT current_date + i FROM generate_series(1, 200, 20) as i;
468
+ SELECT create_range_partitions('subpartitions.abc', 'a', current_date, '1 month'::INTERVAL);
469
+ create_range_partitions
470
+ -------------------------
471
+ 6
472
+ (1 row)
473
+
474
+ SELECT create_range_partitions('subpartitions.abc_1', 'a', current_date + 1,
475
+ '32 day'::INTERVAL, 10); /* not multiple, and limited p_count */
476
+ WARNING: "start_value" was set to 10-02-2017
477
+ WARNING: "p_interval" is not multiple of range (10-02-2017, 11-03-2017)
478
+ NOTICE: "p_count" was limited to 1
479
+ create_range_partitions
480
+ -------------------------
481
+ 1
482
+ (1 row)
483
+
484
+ DROP TABLE subpartitions.abc CASCADE;
485
+ NOTICE: drop cascades to 9 other objects
343
486
DROP SCHEMA subpartitions CASCADE;
344
487
NOTICE: drop cascades to function subpartitions.partitions_tree(regclass,text)
345
488
DROP EXTENSION pg_pathman;
0 commit comments