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

Commitbf826ea

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 parentf7a8fc1 commitbf826ea

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
@@ -1795,6 +1795,12 @@ set_append_references(PlannerInfo *root,
17951795
PartitionedRelPruneInfo*pinfo=lfirst(l2);
17961796

17971797
pinfo->rtindex+=rtoffset;
1798+
pinfo->initial_pruning_steps=
1799+
fix_scan_list(root,pinfo->initial_pruning_steps,
1800+
rtoffset,1);
1801+
pinfo->exec_pruning_steps=
1802+
fix_scan_list(root,pinfo->exec_pruning_steps,
1803+
rtoffset,1);
17981804
}
17991805
}
18001806
}
@@ -1871,6 +1877,12 @@ set_mergeappend_references(PlannerInfo *root,
18711877
PartitionedRelPruneInfo*pinfo=lfirst(l2);
18721878

18731879
pinfo->rtindex+=rtoffset;
1880+
pinfo->initial_pruning_steps=
1881+
fix_scan_list(root,pinfo->initial_pruning_steps,
1882+
rtoffset,1);
1883+
pinfo->exec_pruning_steps=
1884+
fix_scan_list(root,pinfo->exec_pruning_steps,
1885+
rtoffset,1);
18741886
}
18751887
}
18761888
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,35 @@ explain (costs off) select * from rparted_by_int2 where a > 100_000_000_000_000;
18931893
(2 rows)
18941894

18951895
drop table lp, coll_pruning, rlp, mc3p, mc2p, boolpart, iboolpart, boolrangep, rp, coll_pruning_multi, like_op_noprune, lparted_by_int2, rparted_by_int2;
1896+
-- check that AlternativeSubPlan within a pruning expression gets cleaned up
1897+
create table asptab (id int primary key) partition by range (id);
1898+
create table asptab0 partition of asptab for values from (0) to (1);
1899+
create table asptab1 partition of asptab for values from (1) to (2);
1900+
explain (costs off)
1901+
select * from
1902+
(select exists (select 1 from int4_tbl tinner where f1 = touter.f1) as b
1903+
from int4_tbl touter) ss,
1904+
asptab
1905+
where asptab.id > ss.b::int;
1906+
QUERY PLAN
1907+
--------------------------------------------------------------------
1908+
Nested Loop
1909+
-> Seq Scan on int4_tbl touter
1910+
-> Append
1911+
-> Index Only Scan using asptab0_pkey on asptab0 asptab_1
1912+
Index Cond: (id > (EXISTS(SubPlan 3))::integer)
1913+
SubPlan 4
1914+
-> Seq Scan on int4_tbl tinner_2
1915+
-> Index Only Scan using asptab1_pkey on asptab1 asptab_2
1916+
Index Cond: (id > (EXISTS(SubPlan 3))::integer)
1917+
SubPlan 3
1918+
-> Seq Scan on int4_tbl tinner_1
1919+
Filter: (f1 = touter.f1)
1920+
SubPlan 2
1921+
-> Seq Scan on int4_tbl tinner
1922+
(14 rows)
1923+
1924+
drop table asptab;
18961925
--
18971926
-- Test Partition pruning for HASH partitioning
18981927
--

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

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

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

391+
-- check that AlternativeSubPlan within a pruning expression gets cleaned up
392+
393+
createtableasptab (idintprimary key) partition by range (id);
394+
createtableasptab0 partition of asptab forvaluesfrom (0) to (1);
395+
createtableasptab1 partition of asptab forvaluesfrom (1) to (2);
396+
397+
explain (costs off)
398+
select*from
399+
(select exists (select1from int4_tbl tinnerwhere f1=touter.f1)as b
400+
from int4_tbl touter) ss,
401+
asptab
402+
whereasptab.id>ss.b::int;
403+
404+
droptable asptab;
405+
391406
--
392407
-- Test Partition pruning for HASH partitioning
393408
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp