diff options
author | Alvaro Herrera | 2018-08-16 15:43:04 +0000 |
---|---|---|
committer | Alvaro Herrera | 2018-08-16 15:53:43 +0000 |
commit | 1eb9221585c25cad1a563bc3414f697dae3fbc8b (patch) | |
tree | a50d44ced642627e8c8c936c254d88acab732157 /src/test | |
parent | fa73b377ee11ced0c051fb42c29a87b5c71b79e3 (diff) |
Fix executor prune failure when plan already pruned
In a multi-layer partitioning setup, if at plan time all the
sub-partitions are pruned but the intermediate one remains, the executor
later throws a spurious error that there's nothing to prune. That is
correct, but there's no reason to throw an error. Therefore, don't.
Reported-by: Andreas Seltenreich <seltenreich@gmx.de>
Author: David Rowley <david.rowley@2ndquadrant.com>
Discussion: https://postgr.es/m/87in4h98i0.fsf@ansel.ydns.eu
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/partition_prune.out | 18 | ||||
-rw-r--r-- | src/test/regress/sql/partition_prune.sql | 12 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/test/regress/expected/partition_prune.out b/src/test/regress/expected/partition_prune.out index 693c3481854..24313e8c788 100644 --- a/src/test/regress/expected/partition_prune.out +++ b/src/test/regress/expected/partition_prune.out @@ -3570,3 +3570,21 @@ execute q (1, 1); reset plan_cache_mode; drop table p, q; +-- Ensure run-time pruning works correctly when we match a partitioned table +-- on the first level but find no matching partitions on the second level. +create table listp (a int, b int) partition by list (a); +create table listp1 partition of listp for values in(1); +create table listp2 partition of listp for values in(2) partition by list(b); +create table listp2_10 partition of listp2 for values in (10); +explain (analyze, costs off, summary off, timing off) +select * from listp where a = (select 2) and b <> 10; + QUERY PLAN +------------------------------------------- + Append (actual rows=0 loops=1) + InitPlan 1 (returns $0) + -> Result (actual rows=1 loops=1) + -> Seq Scan on listp1 (never executed) + Filter: ((b <> 10) AND (a = $0)) +(5 rows) + +drop table listp; diff --git a/src/test/regress/sql/partition_prune.sql b/src/test/regress/sql/partition_prune.sql index 935c509b29b..eca1a7c5ac9 100644 --- a/src/test/regress/sql/partition_prune.sql +++ b/src/test/regress/sql/partition_prune.sql @@ -946,3 +946,15 @@ execute q (1, 1); reset plan_cache_mode; drop table p, q; + +-- Ensure run-time pruning works correctly when we match a partitioned table +-- on the first level but find no matching partitions on the second level. +create table listp (a int, b int) partition by list (a); +create table listp1 partition of listp for values in(1); +create table listp2 partition of listp for values in(2) partition by list(b); +create table listp2_10 partition of listp2 for values in (10); + +explain (analyze, costs off, summary off, timing off) +select * from listp where a = (select 2) and b <> 10; + +drop table listp; |