Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6589a43

Browse files
committed
Fix executor prune failure when plan already pruned
In a multi-layer partitioning setup, if at plan time all thesub-partitions are pruned but the intermediate one remains, the executorlater throws a spurious error that there's nothing to prune. That iscorrect, 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
1 parent43ba5ac commit6589a43

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

‎src/backend/executor/execPartition.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,8 +1887,13 @@ find_matching_subplans_recurse(PartitionPruningData *prunedata,
18871887
initial_prune,validsubplans);
18881888
else
18891889
{
1890-
/* Shouldn't happen */
1891-
elog(ERROR,"partition missing from subplans");
1890+
/*
1891+
* We get here if the planner already pruned all the sub-
1892+
* partitions for this partition. Silently ignore this
1893+
* partition in this case. The end result is the same: we
1894+
* would have pruned all partitions just the same, but we
1895+
* don't have any pruning steps to execute to verify this.
1896+
*/
18921897
}
18931898
}
18941899
}

‎src/test/regress/expected/partition_prune.out

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,3 +3400,21 @@ where s.a = 1 and s.b = 1 and s.c = (select 1);
34003400
(1 row)
34013401

34023402
drop table p, q;
3403+
-- Ensure run-time pruning works correctly when we match a partitioned table
3404+
-- on the first level but find no matching partitions on the second level.
3405+
create table listp (a int, b int) partition by list (a);
3406+
create table listp1 partition of listp for values in(1);
3407+
create table listp2 partition of listp for values in(2) partition by list(b);
3408+
create table listp2_10 partition of listp2 for values in (10);
3409+
explain (analyze, costs off, summary off, timing off)
3410+
select * from listp where a = (select 2) and b <> 10;
3411+
QUERY PLAN
3412+
-------------------------------------------
3413+
Append (actual rows=0 loops=1)
3414+
InitPlan 1 (returns $0)
3415+
-> Result (actual rows=1 loops=1)
3416+
-> Seq Scan on listp1 (never executed)
3417+
Filter: ((b <> 10) AND (a = $0))
3418+
(5 rows)
3419+
3420+
drop table listp;

‎src/test/regress/sql/partition_prune.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,3 +888,15 @@ from (
888888
wheres.a=1ands.b=1ands.c= (select1);
889889

890890
droptable p, q;
891+
892+
-- Ensure run-time pruning works correctly when we match a partitioned table
893+
-- on the first level but find no matching partitions on the second level.
894+
createtablelistp (aint, bint) partition by list (a);
895+
createtablelistp1 partition of listp forvaluesin(1);
896+
createtablelistp2 partition of listp forvaluesin(2) partition by list(b);
897+
createtablelistp2_10 partition of listp2 forvaluesin (10);
898+
899+
explain (analyze, costs off, summary off, timing off)
900+
select*from listpwhere a= (select2)and b<>10;
901+
902+
droptable listp;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp