From 3821a771a264a9bbd101f434f2bf76c883ece91b Mon Sep 17 00:00:00 2001 From: amit Date: Wed, 21 Dec 2016 10:51:32 +0900 Subject: [PATCH 4/7] Add some more tests for tuple-routing We fixed some issues with how PartitionDispatch related code handled multi-level partitioned tables in commit a25665088d, but didn't add any tests. Reported by: Dmitry Ivanov, Robert Haas Patch by: Amit Langote Reports: /message-id/0d5b64c9-fa05-4dab-93e7-56576d1193ca%40postgrespro.ru /message-id/CA%2BTgmoZ86v1G%2Bzx9etMiSQaBBvYMKfU-iitqZArSh5z0n8Q4cA%40mail.gmail.com --- src/test/regress/expected/insert.out | 38 +++++++++++++++++++++++++++++++++++- src/test/regress/sql/insert.sql | 18 +++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/test/regress/expected/insert.out b/src/test/regress/expected/insert.out index b3cfd44ffd..f4b97bf228 100644 --- a/src/test/regress/expected/insert.out +++ b/src/test/regress/expected/insert.out @@ -285,6 +285,34 @@ select tableoid::regclass, * from list_parted; part_ee_ff2 | EE | 10 (8 rows) +-- some more tests to exercise tuple-routing with multi-level partitioning +create table part_gg partition of list_parted for values in ('gg') partition by range (b); +create table part_gg1 partition of part_gg for values from (unbounded) to (1); +create table part_gg2 partition of part_gg for values from (1) to (10) partition by range (b); +create table part_gg2_1 partition of part_gg2 for values from (1) to (5); +create table part_gg2_2 partition of part_gg2 for values from (5) to (10); +create table part_ee_ff3 partition of part_ee_ff for values from (20) to (30) partition by range (b); +create table part_ee_ff3_1 partition of part_ee_ff3 for values from (20) to (25); +create table part_ee_ff3_2 partition of part_ee_ff3 for values from (25) to (30); +truncate list_parted; +insert into list_parted values ('aa'), ('cc'); +insert into list_parted select 'Ff', s.a from generate_series(1, 29) s(a); +insert into list_parted select 'gg', s.a from generate_series(1, 9) s(a); +insert into list_parted (b) values (1); +select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_parted group by 1, 2 order by 1; + tableoid | a | min_b | max_b +---------------+----+-------+------- + part_aa_bb | aa | | + part_cc_dd | cc | | + part_ee_ff1 | Ff | 1 | 9 + part_ee_ff2 | Ff | 10 | 19 + part_ee_ff3_1 | Ff | 20 | 24 + part_ee_ff3_2 | Ff | 25 | 29 + part_gg2_1 | gg | 1 | 4 + part_gg2_2 | gg | 5 | 9 + part_null | | 1 | 1 +(9 rows) + -- cleanup drop table range_parted cascade; NOTICE: drop cascades to 4 other objects @@ -293,13 +321,21 @@ drop cascades to table part2 drop cascades to table part3 drop cascades to table part4 drop table list_parted cascade; -NOTICE: drop cascades to 6 other objects +NOTICE: drop cascades to 14 other objects DETAIL: drop cascades to table part_aa_bb drop cascades to table part_cc_dd drop cascades to table part_null drop cascades to table part_ee_ff drop cascades to table part_ee_ff1 drop cascades to table part_ee_ff2 +drop cascades to table part_ee_ff3 +drop cascades to table part_ee_ff3_1 +drop cascades to table part_ee_ff3_2 +drop cascades to table part_gg +drop cascades to table part_gg1 +drop cascades to table part_gg2 +drop cascades to table part_gg2_1 +drop cascades to table part_gg2_2 -- more tests for certain multi-level partitioning scenarios create table p (a int, b int) partition by range (a, b); create table p1 (b int, a int not null) partition by range (b); diff --git a/src/test/regress/sql/insert.sql b/src/test/regress/sql/insert.sql index c5a75a505f..1916c9849a 100644 --- a/src/test/regress/sql/insert.sql +++ b/src/test/regress/sql/insert.sql @@ -167,6 +167,24 @@ insert into list_parted values ('EE', 1); insert into part_ee_ff values ('EE', 10); select tableoid::regclass, * from list_parted; +-- some more tests to exercise tuple-routing with multi-level partitioning +create table part_gg partition of list_parted for values in ('gg') partition by range (b); +create table part_gg1 partition of part_gg for values from (unbounded) to (1); +create table part_gg2 partition of part_gg for values from (1) to (10) partition by range (b); +create table part_gg2_1 partition of part_gg2 for values from (1) to (5); +create table part_gg2_2 partition of part_gg2 for values from (5) to (10); + +create table part_ee_ff3 partition of part_ee_ff for values from (20) to (30) partition by range (b); +create table part_ee_ff3_1 partition of part_ee_ff3 for values from (20) to (25); +create table part_ee_ff3_2 partition of part_ee_ff3 for values from (25) to (30); + +truncate list_parted; +insert into list_parted values ('aa'), ('cc'); +insert into list_parted select 'Ff', s.a from generate_series(1, 29) s(a); +insert into list_parted select 'gg', s.a from generate_series(1, 9) s(a); +insert into list_parted (b) values (1); +select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_parted group by 1, 2 order by 1; + -- cleanup drop table range_parted cascade; drop table list_parted cascade; -- 2.11.0