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

Commit5f72564

Browse files
committed
Fix setrefs.c's failure to do expression processing on prune steps.
We should run the expression subtrees of PartitionedRelPruneInfostructs through fix_scan_expr. Failure to do so means thatAlternativeSubPlans within those expressions won't be cleaned upproperly, resulting in "unrecognized node type" errors since v14.It seems fairly likely that at least some of the other steps doneby fix_scan_expr are important here as well, resulting in as-yet-undetected bugs. Therefore, I've chosen to back-patch this toall supported branches including v13, even though the knownsymptom doesn't manifest in v13.Per bug #18778 from Alexander Lakhin.Discussion:https://postgr.es/m/18778-24cd399df6c806af@postgresql.org
1 parent50406b1 commit5f72564

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

‎src/backend/optimizer/plan/setrefs.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,12 @@ set_append_references(PlannerInfo *root,
15681568
PartitionedRelPruneInfo*pinfo=lfirst(l2);
15691569

15701570
pinfo->rtindex+=rtoffset;
1571+
pinfo->initial_pruning_steps=
1572+
fix_scan_list(root,pinfo->initial_pruning_steps,
1573+
rtoffset,1);
1574+
pinfo->exec_pruning_steps=
1575+
fix_scan_list(root,pinfo->exec_pruning_steps,
1576+
rtoffset,1);
15711577
}
15721578
}
15731579
}
@@ -1640,6 +1646,12 @@ set_mergeappend_references(PlannerInfo *root,
16401646
PartitionedRelPruneInfo*pinfo=lfirst(l2);
16411647

16421648
pinfo->rtindex+=rtoffset;
1649+
pinfo->initial_pruning_steps=
1650+
fix_scan_list(root,pinfo->initial_pruning_steps,
1651+
rtoffset,1);
1652+
pinfo->exec_pruning_steps=
1653+
fix_scan_list(root,pinfo->exec_pruning_steps,
1654+
rtoffset,1);
16431655
}
16441656
}
16451657
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,35 @@ explain (costs off) select * from rparted_by_int2 where a > 100000000000000;
18391839
(2 rows)
18401840

18411841
drop table lp, coll_pruning, rlp, mc3p, mc2p, boolpart, iboolpart, boolrangep, rp, coll_pruning_multi, like_op_noprune, lparted_by_int2, rparted_by_int2;
1842+
-- check that AlternativeSubPlan within a pruning expression gets cleaned up
1843+
create table asptab (id int primary key) partition by range (id);
1844+
create table asptab0 partition of asptab for values from (0) to (1);
1845+
create table asptab1 partition of asptab for values from (1) to (2);
1846+
explain (costs off)
1847+
select * from
1848+
(select exists (select 1 from int4_tbl tinner where f1 = touter.f1) as b
1849+
from int4_tbl touter) ss,
1850+
asptab
1851+
where asptab.id > ss.b::int;
1852+
QUERY PLAN
1853+
--------------------------------------------------------------------
1854+
Nested Loop
1855+
-> Seq Scan on int4_tbl touter
1856+
-> Append
1857+
-> Index Only Scan using asptab0_pkey on asptab0 asptab_1
1858+
Index Cond: (id > ((SubPlan 3))::integer)
1859+
SubPlan 4
1860+
-> Seq Scan on int4_tbl tinner_2
1861+
-> Index Only Scan using asptab1_pkey on asptab1 asptab_2
1862+
Index Cond: (id > ((SubPlan 3))::integer)
1863+
SubPlan 3
1864+
-> Seq Scan on int4_tbl tinner_1
1865+
Filter: (f1 = touter.f1)
1866+
SubPlan 2
1867+
-> Seq Scan on int4_tbl tinner
1868+
(14 rows)
1869+
1870+
drop table asptab;
18421871
--
18431872
-- Test Partition pruning for HASH partitioning
18441873
--

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,21 @@ explain (costs off) select * from rparted_by_int2 where a > 100000000000000;
362362

363363
droptable lp, coll_pruning, rlp, mc3p, mc2p, boolpart, iboolpart, boolrangep, rp, coll_pruning_multi, like_op_noprune, lparted_by_int2, rparted_by_int2;
364364

365+
-- check that AlternativeSubPlan within a pruning expression gets cleaned up
366+
367+
createtableasptab (idintprimary key) partition by range (id);
368+
createtableasptab0 partition of asptab forvaluesfrom (0) to (1);
369+
createtableasptab1 partition of asptab forvaluesfrom (1) to (2);
370+
371+
explain (costs off)
372+
select*from
373+
(select exists (select1from int4_tbl tinnerwhere f1=touter.f1)as b
374+
from int4_tbl touter) ss,
375+
asptab
376+
whereasptab.id>ss.b::int;
377+
378+
droptable asptab;
379+
365380
--
366381
-- Test Partition pruning for HASH partitioning
367382
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp