summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/join.out20
-rw-r--r--src/test/regress/sql/join.sql8
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out
index 037c7d0d566..07f5aad5ea4 100644
--- a/src/test/regress/expected/join.out
+++ b/src/test/regress/expected/join.out
@@ -5213,6 +5213,26 @@ SELECT q2 FROM
Index Cond: (id = int8_tbl.q2)
(5 rows)
+-- join removal bug #17773: otherwise-removable PHV appears in a qual condition
+EXPLAIN (VERBOSE, COSTS OFF)
+SELECT q2 FROM
+ (SELECT q2, 'constant'::text AS x
+ FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss
+ RIGHT JOIN int4_tbl ON NULL
+ WHERE x >= x;
+ QUERY PLAN
+------------------------------------------------------
+ Nested Loop Left Join
+ Output: q2
+ Join Filter: NULL::boolean
+ Filter: (('constant'::text) >= ('constant'::text))
+ -> Seq Scan on public.int4_tbl
+ Output: int4_tbl.f1
+ -> Result
+ Output: q2, 'constant'::text
+ One-Time Filter: false
+(9 rows)
+
rollback;
-- another join removal bug: we must clean up correctly when removing a PHV
begin;
diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql
index 1f2b7f62f0f..7157b5cccca 100644
--- a/src/test/regress/sql/join.sql
+++ b/src/test/regress/sql/join.sql
@@ -1888,6 +1888,14 @@ SELECT q2 FROM
FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss
WHERE COALESCE(dat1, 0) = q1;
+-- join removal bug #17773: otherwise-removable PHV appears in a qual condition
+EXPLAIN (VERBOSE, COSTS OFF)
+SELECT q2 FROM
+ (SELECT q2, 'constant'::text AS x
+ FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss
+ RIGHT JOIN int4_tbl ON NULL
+ WHERE x >= x;
+
rollback;
-- another join removal bug: we must clean up correctly when removing a PHV