aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/prep/prepjointree.c5
-rw-r--r--src/test/regress/expected/join.out8
-rw-r--r--src/test/regress/sql/join.sql3
3 files changed, 15 insertions, 1 deletions
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c
index 62a16687963..b164866c729 100644
--- a/src/backend/optimizer/prep/prepjointree.c
+++ b/src/backend/optimizer/prep/prepjointree.c
@@ -1801,10 +1801,13 @@ pull_up_constant_function(PlannerInfo *root, Node *jtnode,
/*
* Convert the RTE to be RTE_RESULT type, signifying that we don't need to
- * scan it anymore, and zero out RTE_FUNCTION-specific fields.
+ * scan it anymore, and zero out RTE_FUNCTION-specific fields. Also make
+ * sure the RTE is not marked LATERAL, since elsewhere we don't expect
+ * RTE_RESULTs to be LATERAL.
*/
rte->rtekind = RTE_RESULT;
rte->functions = NIL;
+ rte->lateral = false;
/*
* We can reuse the RangeTblRef node.
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out
index fec0325e73e..19cd0569876 100644
--- a/src/test/regress/expected/join.out
+++ b/src/test/regress/expected/join.out
@@ -3470,6 +3470,14 @@ select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1;
(2 rows)
explain (costs off)
+select unique1 from tenk1, lateral f_immutable_int4(1) x where x in (select 17);
+ QUERY PLAN
+--------------------------
+ Result
+ One-Time Filter: false
+(2 rows)
+
+explain (costs off)
select unique1, x from tenk1 join f_immutable_int4(1) x on unique1 = x;
QUERY PLAN
----------------------------------------------
diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql
index 7f866c603b8..2a0e2d12d83 100644
--- a/src/test/regress/sql/join.sql
+++ b/src/test/regress/sql/join.sql
@@ -1114,6 +1114,9 @@ explain (costs off)
select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1;
explain (costs off)
+select unique1 from tenk1, lateral f_immutable_int4(1) x where x in (select 17);
+
+explain (costs off)
select unique1, x from tenk1 join f_immutable_int4(1) x on unique1 = x;
explain (costs off)