From d496efdde60ba62ad0420bfc7e5d3b57f89e263a Mon Sep 17 00:00:00 2001 From: amit Date: Fri, 10 May 2019 13:52:41 +0900 Subject: [PATCH v2 1/2] Add test --- src/test/regress/expected/partition_prune.out | 31 +++++++++++++++++++++++++++ src/test/regress/sql/partition_prune.sql | 8 +++++++ 2 files changed, 39 insertions(+) diff --git a/src/test/regress/expected/partition_prune.out b/src/test/regress/expected/partition_prune.out index bd64bed8fc..80dc700323 100644 --- a/src/test/regress/expected/partition_prune.out +++ b/src/test/regress/expected/partition_prune.out @@ -920,6 +920,37 @@ explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1) or (a = 10 a Filter: (((a = 1) AND (abs(b) = 1)) OR ((a = 10) AND (abs(b) = 9))) (9 rows) +-- +-- Check that pruning with composite range partitioning works correctly +-- correctly in the face of combination of static and runtime values being +-- passed to perform plan-time pruning with +-- +explain (analyze, costs off, summary off, timing off) select * from mc3p where a = 1 and abs(b) < (select 2); + QUERY PLAN +-------------------------------------------------------- + Append (actual rows=0 loops=1) + InitPlan 1 (returns $0) + -> Result (actual rows=1 loops=1) + -> Seq Scan on mc3p0 (actual rows=0 loops=1) + Filter: ((a = 1) AND (abs(b) < $0)) + -> Seq Scan on mc3p_default (actual rows=0 loops=1) + Filter: ((a = 1) AND (abs(b) < $0)) +(7 rows) + +explain (analyze, costs off, summary off, timing off) select * from mc3p where a < (select 1) and abs(b) = 1; + QUERY PLAN +-------------------------------------------------------- + Append (actual rows=0 loops=1) + InitPlan 1 (returns $0) + -> Result (actual rows=1 loops=1) + -> Seq Scan on mc3p0 (actual rows=0 loops=1) + Filter: ((a < $0) AND (abs(b) = 1)) + -> Seq Scan on mc3p1 (never executed) + Filter: ((a < $0) AND (abs(b) = 1)) + -> Seq Scan on mc3p_default (actual rows=0 loops=1) + Filter: ((a < $0) AND (abs(b) = 1)) +(9 rows) + -- a simpler multi-column keys case create table mc2p (a int, b int) partition by range (a, b); create table mc2p_default partition of mc2p default; diff --git a/src/test/regress/sql/partition_prune.sql b/src/test/regress/sql/partition_prune.sql index 246c6274af..66489dff63 100644 --- a/src/test/regress/sql/partition_prune.sql +++ b/src/test/regress/sql/partition_prune.sql @@ -122,6 +122,14 @@ explain (costs off) select * from mc3p where a = 1 or abs(b) = 1 or c = 1; explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1) or (a = 10 and abs(b) = 10); explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1) or (a = 10 and abs(b) = 9); +-- +-- Check that pruning with composite range partitioning works correctly +-- correctly in the face of combination of static and runtime values being +-- passed to perform plan-time pruning with +-- +explain (analyze, costs off, summary off, timing off) select * from mc3p where a = 1 and abs(b) < (select 2); +explain (analyze, costs off, summary off, timing off) select * from mc3p where a < (select 1) and abs(b) = 1; + -- a simpler multi-column keys case create table mc2p (a int, b int) partition by range (a, b); create table mc2p_default partition of mc2p default; -- 2.11.0