@@ -316,75 +316,75 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
316316-- cleanup
317317drop table range_parted, list_parted;
318318-- 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
327327select attrelid::regclass, attname, attnum
328328from pg_attribute
329329where 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)
333333order 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
339339(3 rows)
340340
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
349349(1 row)
350350
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
354354DETAIL: 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
358358-- 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"
361361DETAIL: Failing row contains (1, 2).
362362-- check that inserting into an internal partition successfully results in
363363-- checking its partition constraint before inserting into the leaf partition
364364-- 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
367367DETAIL: Failing row contains (3, 2).
368368-- 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);
378378with 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, *)
380380 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
388388(5 rows)
389389
390390-- check that message shown after failure to find a partition shows the
@@ -413,5 +413,3 @@ revoke all on key_desc from someone_else;
413413revoke all on key_desc_1 from someone_else;
414414drop role someone_else;
415415drop table key_desc, key_desc_1;
416- -- cleanup
417- drop table p;