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

Commit9807b9a

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 parent55cccdf commit9807b9a

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
@@ -1802,10 +1802,13 @@ pull_up_constant_function(PlannerInfo *root, Node *jtnode,
18021802

18031803
/*
18041804
* Convert the RTE to be RTE_RESULT type, signifying that we don't need to
1805-
* scan it anymore, and zero out RTE_FUNCTION-specific fields.
1805+
* scan it anymore, and zero out RTE_FUNCTION-specific fields. Also make
1806+
* sure the RTE is not marked LATERAL, since elsewhere we don't expect
1807+
* RTE_RESULTs to be LATERAL.
18061808
*/
18071809
rte->rtekind=RTE_RESULT;
18081810
rte->functions=NIL;
1811+
rte->lateral= false;
18091812

18101813
/*
18111814
* 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
@@ -3414,6 +3414,14 @@ select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1;
34143414
Index Cond: (unique1 = 1)
34153415
(2 rows)
34163416

3417+
explain (costs off)
3418+
select unique1 from tenk1, lateral f_immutable_int4(1) x where x in (select 17);
3419+
QUERY PLAN
3420+
--------------------------
3421+
Result
3422+
One-Time Filter: false
3423+
(2 rows)
3424+
34173425
explain (costs off)
34183426
select unique1, x from tenk1 join f_immutable_int4(1) x on unique1 = x;
34193427
QUERY PLAN

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

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

1102+
explain (costs off)
1103+
select unique1from tenk1, lateral f_immutable_int4(1) xwhere xin (select17);
1104+
11021105
explain (costs off)
11031106
select unique1, xfrom tenk1join f_immutable_int4(1) xon unique1= x;
11041107

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp