@@ -316,75 +316,75 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
316
316
-- cleanup
317
317
drop table range_parted, list_parted;
318
318
-- more tests for certain multi-level partitioning scenarios
319
- create tablep (a int, b int) partition by range (a, b);
320
- create tablep1 (b int not null, a int not null) partition by range ((b+0));
321
- create tablep11 (likep1 );
322
- alter tablep11 drop a;
323
- alter tablep11 add a int;
324
- alter tablep11 drop a;
325
- alter tablep11 add a int not null;
326
- -- attnum for key attribute 'a' is different inp, p1 , andp11
319
+ create tablemlparted (a int, b int) partition by range (a, b);
320
+ create tablemlparted1 (b int not null, a int not null) partition by range ((b+0));
321
+ create tablemlparted11 (likemlparted1 );
322
+ alter tablemlparted11 drop a;
323
+ alter tablemlparted11 add a int;
324
+ alter tablemlparted11 drop a;
325
+ alter tablemlparted11 add a int not null;
326
+ -- attnum for key attribute 'a' is different inmlparted, mlparted1 , andmlparted11
327
327
select attrelid::regclass, attname, attnum
328
328
from pg_attribute
329
329
where attname = 'a'
330
- and (attrelid = 'p '::regclass
331
- or attrelid = 'p1 '::regclass
332
- or attrelid = 'p11 '::regclass)
330
+ and (attrelid = 'mlparted '::regclass
331
+ or attrelid = 'mlparted1 '::regclass
332
+ or attrelid = 'mlparted11 '::regclass)
333
333
order by attrelid::regclass::text;
334
- attrelid | attname | attnum
335
- ----------+---------+--------
336
- p | a | 1
337
- p1 | a | 2
338
- p11 | a | 4
334
+ attrelid | attname | attnum
335
+ ------------ +---------+--------
336
+ mlparted | a | 1
337
+ mlparted1 | a | 2
338
+ mlparted11 | a | 4
339
339
(3 rows)
340
340
341
- alter tablep1 attach partitionp11 for values from (2) to (5);
342
- alter tablep attach partitionp1 for values from (1, 2) to (1, 10);
343
- -- check that "(1, 2)" is correctly routed top11 .
344
- insert intop values (1, 2);
345
- select tableoid::regclass, * fromp ;
346
- tableoid | a | b
347
- ----------+---+---
348
- p11 | 1 | 2
341
+ alter tablemlparted1 attach partitionmlparted11 for values from (2) to (5);
342
+ alter tablemlparted attach partitionmlparted1 for values from (1, 2) to (1, 10);
343
+ -- check that "(1, 2)" is correctly routed tomlparted11 .
344
+ insert intomlparted values (1, 2);
345
+ select tableoid::regclass, * frommlparted ;
346
+ tableoid | a | b
347
+ ------------ +---+---
348
+ mlparted11 | 1 | 2
349
349
(1 row)
350
350
351
- -- check that proper message is shown after failure to route throughp1
352
- insert intop (a, b) values (1, 5);
353
- ERROR: no partition of relation "p1 " found for row
351
+ -- check that proper message is shown after failure to route throughmlparted1
352
+ insert intomlparted (a, b) values (1, 5);
353
+ ERROR: no partition of relation "mlparted1 " found for row
354
354
DETAIL: Partition key of the failing row contains ((b + 0)) = (5).
355
- truncatep ;
356
- alter tablep add constraint check_b check (b = 3);
357
- -- check that correct input row is shown when constraint check_b fails onp11
355
+ truncatemlparted ;
356
+ alter tablemlparted add constraint check_b check (b = 3);
357
+ -- check that correct input row is shown when constraint check_b fails onmlparted11
358
358
-- after "(1, 2)" is routed to it
359
- insert intop values (1, 2);
360
- ERROR: new row for relation "p11 " violates check constraint "check_b"
359
+ insert intomlparted values (1, 2);
360
+ ERROR: new row for relation "mlparted11 " violates check constraint "check_b"
361
361
DETAIL: Failing row contains (1, 2).
362
362
-- check that inserting into an internal partition successfully results in
363
363
-- checking its partition constraint before inserting into the leaf partition
364
364
-- selected by tuple-routing
365
- insert intop1 (a, b) values (2, 3);
366
- ERROR: new row for relation "p11 " violates partition constraint
365
+ insert intomlparted1 (a, b) values (2, 3);
366
+ ERROR: new row for relation "mlparted11 " violates partition constraint
367
367
DETAIL: Failing row contains (3, 2).
368
368
-- check that RETURNING works correctly with tuple-routing
369
- alter tablep drop constraint check_b;
370
- create tablep12 partition ofp1 for values from (5) to (10);
371
- create tablep2 (b int not null, a int not null);
372
- alter tablep attach partitionp2 for values from (1, 10) to (1, 20);
373
- create tablep3 partition ofp for values from (1, 20) to (1, 30);
374
- create tablep4 (likep );
375
- alter tablep4 drop a;
376
- alter tablep4 add a int not null;
377
- alter tablep attach partitionp4 for values from (1, 30) to (1, 40);
369
+ alter tablemlparted drop constraint check_b;
370
+ create tablemlparted12 partition ofmlparted1 for values from (5) to (10);
371
+ create tablemlparted2 (b int not null, a int not null);
372
+ alter tablemlparted attach partitionmlparted2 for values from (1, 10) to (1, 20);
373
+ create tablemlparted3 partition ofmlparted for values from (1, 20) to (1, 30);
374
+ create tablemlparted4 (likemlparted );
375
+ alter tablemlparted4 drop a;
376
+ alter tablemlparted4 add a int not null;
377
+ alter tablemlparted attach partitionmlparted4 for values from (1, 30) to (1, 40);
378
378
with ins (a, b, c) as
379
- (insert intop (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *)
379
+ (insert intomlparted (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *)
380
380
select a, b, min(c), max(c) from ins group by a, b order by 1;
381
- a | b | min | max
382
- -----+---+-----+-----
383
- p11 | 1 | 2 | 4
384
- p12 | 1 | 5 | 9
385
- p2 | 1 | 10 | 19
386
- p3 | 1 | 20 | 29
387
- p4 | 1 | 30 | 39
381
+ a | b | min | max
382
+ ------------ +---+-----+-----
383
+ mlparted11 | 1 | 2 | 4
384
+ mlparted12 | 1 | 5 | 9
385
+ mlparted2 | 1 | 10 | 19
386
+ mlparted3 | 1 | 20 | 29
387
+ mlparted4 | 1 | 30 | 39
388
388
(5 rows)
389
389
390
390
-- check that message shown after failure to find a partition shows the
@@ -413,5 +413,3 @@ revoke all on key_desc from someone_else;
413
413
revoke all on key_desc_1 from someone_else;
414
414
drop role someone_else;
415
415
drop table key_desc, key_desc_1;
416
- -- cleanup
417
- drop table p;