Commit 964bae4d authored by Michael Paquier's avatar Michael Paquier

Add more tests for partition tuple routing with dropped attributes

As bug #15733 has proved, we are lacking coverage for partition tuple
routing with dropped attributes when involving three levels of
partitioning or more.  There was only an active bug in this area for
v11, and HEAD is proving to handle those scenarios fine, still it lacked
some coverage for the previous problem.

Author: Amit Langote, Michael Paquier
Discussion: https://postgr.es/m/15733-7692379e310b80ec@postgresql.org
parent 80a96e06
......@@ -629,6 +629,47 @@ select tableoid::regclass, * from mlparted_def;
mlparted_defd | 70 | 100 |
(4 rows)
-- Check multi-level tuple routing with attributes dropped from the
-- top-most parent. First remove the last attribute.
alter table mlparted add d int, add e int;
alter table mlparted drop e;
create table mlparted5 partition of mlparted
for values from (1, 40) to (1, 50) partition by range (c);
create table mlparted5_ab partition of mlparted5
for values from ('a') to ('c') partition by list (c);
create table mlparted5_a partition of mlparted5_ab for values in ('a');
create table mlparted5_b (d int, b int, c text, a int);
alter table mlparted5_ab attach partition mlparted5_b for values in ('b');
truncate mlparted;
insert into mlparted values (1, 2, 'a', 1);
insert into mlparted values (1, 40, 'a', 1); -- goes to mlparted5_a
insert into mlparted values (1, 45, 'b', 1); -- goes to mlparted5_b
select tableoid::regclass, * from mlparted order by a, b, c, d;
tableoid | a | b | c | d
-------------+---+----+---+---
mlparted11 | 1 | 2 | a | 1
mlparted5_a | 1 | 40 | a | 1
mlparted5_b | 1 | 45 | b | 1
(3 rows)
alter table mlparted drop d;
truncate mlparted;
-- Remove the before last attribute.
alter table mlparted add e int, add d int;
alter table mlparted drop e;
insert into mlparted values (1, 2, 'a', 1);
insert into mlparted values (1, 40, 'a', 1); -- goes to mlparted5_a
insert into mlparted values (1, 45, 'b', 1); -- goes to mlparted5_b
select tableoid::regclass, * from mlparted order by a, b, c, d;
tableoid | a | b | c | d
-------------+---+----+---+---
mlparted11 | 1 | 2 | a | 1
mlparted5_a | 1 | 40 | a | 1
mlparted5_b | 1 | 45 | b | 1
(3 rows)
alter table mlparted drop d;
drop table mlparted5;
-- check that message shown after failure to find a partition shows the
-- appropriate key description (or none) in various situations
create table key_desc (a int, b int) partition by list ((a+0));
......
......@@ -401,6 +401,34 @@ insert into mlparted values (70, 100);
select tableoid::regclass, * from mlparted_def;
-- Check multi-level tuple routing with attributes dropped from the
-- top-most parent. First remove the last attribute.
alter table mlparted add d int, add e int;
alter table mlparted drop e;
create table mlparted5 partition of mlparted
for values from (1, 40) to (1, 50) partition by range (c);
create table mlparted5_ab partition of mlparted5
for values from ('a') to ('c') partition by list (c);
create table mlparted5_a partition of mlparted5_ab for values in ('a');
create table mlparted5_b (d int, b int, c text, a int);
alter table mlparted5_ab attach partition mlparted5_b for values in ('b');
truncate mlparted;
insert into mlparted values (1, 2, 'a', 1);
insert into mlparted values (1, 40, 'a', 1); -- goes to mlparted5_a
insert into mlparted values (1, 45, 'b', 1); -- goes to mlparted5_b
select tableoid::regclass, * from mlparted order by a, b, c, d;
alter table mlparted drop d;
truncate mlparted;
-- Remove the before last attribute.
alter table mlparted add e int, add d int;
alter table mlparted drop e;
insert into mlparted values (1, 2, 'a', 1);
insert into mlparted values (1, 40, 'a', 1); -- goes to mlparted5_a
insert into mlparted values (1, 45, 'b', 1); -- goes to mlparted5_b
select tableoid::regclass, * from mlparted order by a, b, c, d;
alter table mlparted drop d;
drop table mlparted5;
-- check that message shown after failure to find a partition shows the
-- appropriate key description (or none) in various situations
create table key_desc (a int, b int) partition by list ((a+0));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment