summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-07-09 13:38:24 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-07-09 13:38:24 -0400
commit1d98fdaed89c00465ef68fa2804967ea27b03abc (patch)
treeb656031eae66d73a82faeb4fa4e40d707557f366 /src/test
parent5620ec83362d08b9f86c90c97c0a70031c4d0b2c (diff)
Avoid creating a RESULT RTE that's marked LATERAL.
Commit 7266d0997 added code to pull up simple constant function results, converting the RTE_FUNCTION RTE to a dummy RTE_RESULT RTE since it no longer need be scanned. But I forgot to clear the LATERAL flag if the RTE has it set. If the function reduced to a constant, it surely contains no lateral references so this simplification is logically OK. It's needed because various other places will Assert that RESULT RTEs aren't LATERAL. Per bug #17097 from Yaoguang Chen. Back-patch to v13 where the faulty code came in. Discussion: https://postgr.es/m/17097-3372ef9f798fc94f@postgresql.org
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/join.out8
-rw-r--r--src/test/regress/sql/join.sql3
2 files changed, 11 insertions, 0 deletions
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)