Commit aa566718 authored by Robert Haas's avatar Robert Haas

Give partitioned table "p" in regression tests a less generic name.

And don't drop it, so that we improve the coverage of the pg_upgrade
regression tests.

Amit Langote, per a gripe from Tom Lane

Discussion: http://postgr.es/m/9071.1488863082@sss.pgh.pa.us
parent d88d06cd
...@@ -3371,3 +3371,4 @@ alter table p attach partition p1 for values from (1, 2) to (1, 10); ...@@ -3371,3 +3371,4 @@ alter table p attach partition p1 for values from (1, 2) to (1, 10);
ERROR: partition constraint is violated by some row ERROR: partition constraint is violated by some row
-- cleanup -- cleanup
drop table p; drop table p;
drop table p1;
...@@ -316,75 +316,75 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p ...@@ -316,75 +316,75 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
-- cleanup -- cleanup
drop table range_parted, list_parted; drop table range_parted, list_parted;
-- more tests for certain multi-level partitioning scenarios -- more tests for certain multi-level partitioning scenarios
create table p (a int, b int) partition by range (a, b); create table mlparted (a int, b int) partition by range (a, b);
create table p1 (b int not null, a int not null) partition by range ((b+0)); create table mlparted1 (b int not null, a int not null) partition by range ((b+0));
create table p11 (like p1); create table mlparted11 (like mlparted1);
alter table p11 drop a; alter table mlparted11 drop a;
alter table p11 add a int; alter table mlparted11 add a int;
alter table p11 drop a; alter table mlparted11 drop a;
alter table p11 add a int not null; alter table mlparted11 add a int not null;
-- attnum for key attribute 'a' is different in p, p1, and p11 -- attnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11
select attrelid::regclass, attname, attnum select attrelid::regclass, attname, attnum
from pg_attribute from pg_attribute
where attname = 'a' where attname = 'a'
and (attrelid = 'p'::regclass and (attrelid = 'mlparted'::regclass
or attrelid = 'p1'::regclass or attrelid = 'mlparted1'::regclass
or attrelid = 'p11'::regclass) or attrelid = 'mlparted11'::regclass)
order by attrelid::regclass::text; order by attrelid::regclass::text;
attrelid | attname | attnum attrelid | attname | attnum
----------+---------+-------- ------------+---------+--------
p | a | 1 mlparted | a | 1
p1 | a | 2 mlparted1 | a | 2
p11 | a | 4 mlparted11 | a | 4
(3 rows) (3 rows)
alter table p1 attach partition p11 for values from (2) to (5); alter table mlparted1 attach partition mlparted11 for values from (2) to (5);
alter table p attach partition p1 for values from (1, 2) to (1, 10); alter table mlparted attach partition mlparted1 for values from (1, 2) to (1, 10);
-- check that "(1, 2)" is correctly routed to p11. -- check that "(1, 2)" is correctly routed to mlparted11.
insert into p values (1, 2); insert into mlparted values (1, 2);
select tableoid::regclass, * from p; select tableoid::regclass, * from mlparted;
tableoid | a | b tableoid | a | b
----------+---+--- ------------+---+---
p11 | 1 | 2 mlparted11 | 1 | 2
(1 row) (1 row)
-- check that proper message is shown after failure to route through p1 -- check that proper message is shown after failure to route through mlparted1
insert into p (a, b) values (1, 5); insert into mlparted (a, b) values (1, 5);
ERROR: no partition of relation "p1" found for row ERROR: no partition of relation "mlparted1" found for row
DETAIL: Partition key of the failing row contains ((b + 0)) = (5). DETAIL: Partition key of the failing row contains ((b + 0)) = (5).
truncate p; truncate mlparted;
alter table p add constraint check_b check (b = 3); alter table mlparted add constraint check_b check (b = 3);
-- check that correct input row is shown when constraint check_b fails on p11 -- check that correct input row is shown when constraint check_b fails on mlparted11
-- after "(1, 2)" is routed to it -- after "(1, 2)" is routed to it
insert into p values (1, 2); insert into mlparted values (1, 2);
ERROR: new row for relation "p11" violates check constraint "check_b" ERROR: new row for relation "mlparted11" violates check constraint "check_b"
DETAIL: Failing row contains (1, 2). DETAIL: Failing row contains (1, 2).
-- check that inserting into an internal partition successfully results in -- check that inserting into an internal partition successfully results in
-- checking its partition constraint before inserting into the leaf partition -- checking its partition constraint before inserting into the leaf partition
-- selected by tuple-routing -- selected by tuple-routing
insert into p1 (a, b) values (2, 3); insert into mlparted1 (a, b) values (2, 3);
ERROR: new row for relation "p11" violates partition constraint ERROR: new row for relation "mlparted11" violates partition constraint
DETAIL: Failing row contains (3, 2). DETAIL: Failing row contains (3, 2).
-- check that RETURNING works correctly with tuple-routing -- check that RETURNING works correctly with tuple-routing
alter table p drop constraint check_b; alter table mlparted drop constraint check_b;
create table p12 partition of p1 for values from (5) to (10); create table mlparted12 partition of mlparted1 for values from (5) to (10);
create table p2 (b int not null, a int not null); create table mlparted2 (b int not null, a int not null);
alter table p attach partition p2 for values from (1, 10) to (1, 20); alter table mlparted attach partition mlparted2 for values from (1, 10) to (1, 20);
create table p3 partition of p for values from (1, 20) to (1, 30); create table mlparted3 partition of mlparted for values from (1, 20) to (1, 30);
create table p4 (like p); create table mlparted4 (like mlparted);
alter table p4 drop a; alter table mlparted4 drop a;
alter table p4 add a int not null; alter table mlparted4 add a int not null;
alter table p attach partition p4 for values from (1, 30) to (1, 40); alter table mlparted attach partition mlparted4 for values from (1, 30) to (1, 40);
with ins (a, b, c) as with ins (a, b, c) as
(insert into p (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *) (insert into mlparted (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *)
select a, b, min(c), max(c) from ins group by a, b order by 1; select a, b, min(c), max(c) from ins group by a, b order by 1;
a | b | min | max a | b | min | max
-----+---+-----+----- ------------+---+-----+-----
p11 | 1 | 2 | 4 mlparted11 | 1 | 2 | 4
p12 | 1 | 5 | 9 mlparted12 | 1 | 5 | 9
p2 | 1 | 10 | 19 mlparted2 | 1 | 10 | 19
p3 | 1 | 20 | 29 mlparted3 | 1 | 20 | 29
p4 | 1 | 30 | 39 mlparted4 | 1 | 30 | 39
(5 rows) (5 rows)
-- check that message shown after failure to find a partition shows the -- 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,5 +413,3 @@ revoke all on key_desc from someone_else;
revoke all on key_desc_1 from someone_else; revoke all on key_desc_1 from someone_else;
drop role someone_else; drop role someone_else;
drop table key_desc, key_desc_1; drop table key_desc, key_desc_1;
-- cleanup
drop table p;
...@@ -9,7 +9,7 @@ VACUUM; ...@@ -9,7 +9,7 @@ VACUUM;
\a\t \a\t
SELECT relname, relhasindex SELECT relname, relhasindex
FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
WHERE relkind = 'r' AND (nspname ~ '^pg_temp_') IS NOT TRUE WHERE relkind IN ('r', 'P') AND (nspname ~ '^pg_temp_') IS NOT TRUE
ORDER BY relname; ORDER BY relname;
a|f a|f
a_star|f a_star|f
...@@ -70,6 +70,13 @@ line_tbl|f ...@@ -70,6 +70,13 @@ line_tbl|f
log_table|f log_table|f
lseg_tbl|f lseg_tbl|f
main_table|f main_table|f
mlparted|f
mlparted1|f
mlparted11|f
mlparted12|f
mlparted2|f
mlparted3|f
mlparted4|f
money_data|f money_data|f
num_data|f num_data|f
num_exp_add|t num_exp_add|t
......
...@@ -2227,3 +2227,4 @@ alter table p attach partition p1 for values from (1, 2) to (1, 10); ...@@ -2227,3 +2227,4 @@ alter table p attach partition p1 for values from (1, 2) to (1, 10);
-- cleanup -- cleanup
drop table p; drop table p;
drop table p1;
...@@ -189,55 +189,55 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p ...@@ -189,55 +189,55 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
drop table range_parted, list_parted; drop table range_parted, list_parted;
-- more tests for certain multi-level partitioning scenarios -- more tests for certain multi-level partitioning scenarios
create table p (a int, b int) partition by range (a, b); create table mlparted (a int, b int) partition by range (a, b);
create table p1 (b int not null, a int not null) partition by range ((b+0)); create table mlparted1 (b int not null, a int not null) partition by range ((b+0));
create table p11 (like p1); create table mlparted11 (like mlparted1);
alter table p11 drop a; alter table mlparted11 drop a;
alter table p11 add a int; alter table mlparted11 add a int;
alter table p11 drop a; alter table mlparted11 drop a;
alter table p11 add a int not null; alter table mlparted11 add a int not null;
-- attnum for key attribute 'a' is different in p, p1, and p11 -- attnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11
select attrelid::regclass, attname, attnum select attrelid::regclass, attname, attnum
from pg_attribute from pg_attribute
where attname = 'a' where attname = 'a'
and (attrelid = 'p'::regclass and (attrelid = 'mlparted'::regclass
or attrelid = 'p1'::regclass or attrelid = 'mlparted1'::regclass
or attrelid = 'p11'::regclass) or attrelid = 'mlparted11'::regclass)
order by attrelid::regclass::text; order by attrelid::regclass::text;
alter table p1 attach partition p11 for values from (2) to (5); alter table mlparted1 attach partition mlparted11 for values from (2) to (5);
alter table p attach partition p1 for values from (1, 2) to (1, 10); alter table mlparted attach partition mlparted1 for values from (1, 2) to (1, 10);
-- check that "(1, 2)" is correctly routed to p11. -- check that "(1, 2)" is correctly routed to mlparted11.
insert into p values (1, 2); insert into mlparted values (1, 2);
select tableoid::regclass, * from p; select tableoid::regclass, * from mlparted;
-- check that proper message is shown after failure to route through p1 -- check that proper message is shown after failure to route through mlparted1
insert into p (a, b) values (1, 5); insert into mlparted (a, b) values (1, 5);
truncate p; truncate mlparted;
alter table p add constraint check_b check (b = 3); alter table mlparted add constraint check_b check (b = 3);
-- check that correct input row is shown when constraint check_b fails on p11 -- check that correct input row is shown when constraint check_b fails on mlparted11
-- after "(1, 2)" is routed to it -- after "(1, 2)" is routed to it
insert into p values (1, 2); insert into mlparted values (1, 2);
-- check that inserting into an internal partition successfully results in -- check that inserting into an internal partition successfully results in
-- checking its partition constraint before inserting into the leaf partition -- checking its partition constraint before inserting into the leaf partition
-- selected by tuple-routing -- selected by tuple-routing
insert into p1 (a, b) values (2, 3); insert into mlparted1 (a, b) values (2, 3);
-- check that RETURNING works correctly with tuple-routing -- check that RETURNING works correctly with tuple-routing
alter table p drop constraint check_b; alter table mlparted drop constraint check_b;
create table p12 partition of p1 for values from (5) to (10); create table mlparted12 partition of mlparted1 for values from (5) to (10);
create table p2 (b int not null, a int not null); create table mlparted2 (b int not null, a int not null);
alter table p attach partition p2 for values from (1, 10) to (1, 20); alter table mlparted attach partition mlparted2 for values from (1, 10) to (1, 20);
create table p3 partition of p for values from (1, 20) to (1, 30); create table mlparted3 partition of mlparted for values from (1, 20) to (1, 30);
create table p4 (like p); create table mlparted4 (like mlparted);
alter table p4 drop a; alter table mlparted4 drop a;
alter table p4 add a int not null; alter table mlparted4 add a int not null;
alter table p attach partition p4 for values from (1, 30) to (1, 40); alter table mlparted attach partition mlparted4 for values from (1, 30) to (1, 40);
with ins (a, b, c) as with ins (a, b, c) as
(insert into p (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *) (insert into mlparted (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *)
select a, b, min(c), max(c) from ins group by a, b order by 1; select a, b, min(c), max(c) from ins group by a, b order by 1;
-- check that message shown after failure to find a partition shows the -- check that message shown after failure to find a partition shows the
...@@ -266,6 +266,3 @@ revoke all on key_desc from someone_else; ...@@ -266,6 +266,3 @@ revoke all on key_desc from someone_else;
revoke all on key_desc_1 from someone_else; revoke all on key_desc_1 from someone_else;
drop role someone_else; drop role someone_else;
drop table key_desc, key_desc_1; drop table key_desc, key_desc_1;
-- cleanup
drop table p;
...@@ -12,7 +12,7 @@ VACUUM; ...@@ -12,7 +12,7 @@ VACUUM;
SELECT relname, relhasindex SELECT relname, relhasindex
FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
WHERE relkind = 'r' AND (nspname ~ '^pg_temp_') IS NOT TRUE WHERE relkind IN ('r', 'P') AND (nspname ~ '^pg_temp_') IS NOT TRUE
ORDER BY relname; ORDER BY relname;
-- restore normal output mode -- restore normal output mode
......
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