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

Commitd23ac62

Browse files
committed
Avoid creating a RESULT RTE that's marked LATERAL.
Commit7266d09 added code to pull up simple constant functionresults, converting the RTE_FUNCTION RTE to a dummy RTE_RESULTRTE since it no longer need be scanned. But I forgot to clearthe LATERAL flag if the RTE has it set. If the function reducedto a constant, it surely contains no lateral references so thissimplification is logically OK. It's needed because various otherplaces will Assert that RESULT RTEs aren't LATERAL.Per bug #17097 from Yaoguang Chen. Back-patch to v13 where thefaulty code came in.Discussion:https://postgr.es/m/17097-3372ef9f798fc94f@postgresql.org
1 parentd0a02bd commitd23ac62

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

‎src/backend/optimizer/prep/prepjointree.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,10 +1808,13 @@ pull_up_constant_function(PlannerInfo *root, Node *jtnode,
18081808

18091809
/*
18101810
* Convert the RTE to be RTE_RESULT type, signifying that we don't need to
1811-
* scan it anymore, and zero out RTE_FUNCTION-specific fields.
1811+
* scan it anymore, and zero out RTE_FUNCTION-specific fields. Also make
1812+
* sure the RTE is not marked LATERAL, since elsewhere we don't expect
1813+
* RTE_RESULTs to be LATERAL.
18121814
*/
18131815
rte->rtekind=RTE_RESULT;
18141816
rte->functions=NIL;
1817+
rte->lateral= false;
18151818

18161819
/*
18171820
* We can reuse the RangeTblRef node.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3469,6 +3469,14 @@ select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1;
34693469
Index Cond: (unique1 = 1)
34703470
(2 rows)
34713471

3472+
explain (costs off)
3473+
select unique1 from tenk1, lateral f_immutable_int4(1) x where x in (select 17);
3474+
QUERY PLAN
3475+
--------------------------
3476+
Result
3477+
One-Time Filter: false
3478+
(2 rows)
3479+
34723480
explain (costs off)
34733481
select unique1, x from tenk1 join f_immutable_int4(1) x on unique1 = x;
34743482
QUERY PLAN

‎src/test/regress/sql/join.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,9 @@ select unique1 from tenk1, f_immutable_int4(1) x where x = unique1;
11131113
explain (costs off)
11141114
select unique1from tenk1, lateral f_immutable_int4(1) xwhere x= unique1;
11151115

1116+
explain (costs off)
1117+
select unique1from tenk1, lateral f_immutable_int4(1) xwhere xin (select17);
1118+
11161119
explain (costs off)
11171120
select unique1, xfrom tenk1join f_immutable_int4(1) xon unique1= x;
11181121

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp