diff options
author | Alexander Korotkov | 2025-04-29 11:34:44 +0000 |
---|---|---|
committer | Alexander Korotkov | 2025-04-29 11:34:44 +0000 |
commit | 2260c7f6d90ecf76d3806d32890a0890688b41e8 (patch) | |
tree | ca339e2ad4f5db7da9c05b8b9f7e7ff6d83c9cdb /src/test/regress/expected/join.out | |
parent | 15b1b4dd3fccfd2576f44841863153c312de011b (diff) |
Fixes for ChangeVarNodes_walker()
This commit fixes two bug in ChangeVarNodes_walker() function.
* When considering RestrictInfo, walk down to its clauses based on the
presense of relid to be deleted not just in clause_relids but also in
required_relids.
* Incrementally adjust num_base_rels based on the change of clause_relids
instead of recalculating it using clause_relids, which could contain
outer-join relids.
Reported-by: Richard Guo <[email protected]>
Discussion: https://postgr.es/m/CAMbWs49PE3CvnV8vrQ0Dr%3DHqgZZmX0tdNbzVNJxqc8yg-8kDQQ%40mail.gmail.com
Author: Andrei Lepikhov <[email protected]>
Reviewed-by: Alexander Korotkov <[email protected]>
Diffstat (limited to 'src/test/regress/expected/join.out')
-rw-r--r-- | src/test/regress/expected/join.out | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index fa2c7405519..f35a0b18c37 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -7260,7 +7260,21 @@ WHERE t1.id = emp1.id RETURNING emp1.id, emp1.code, t1.code; Index Cond: (id = emp1.id) (5 rows) -INSERT INTO emp1 VALUES (1, 1), (2, 1); +-- Check that SJE correctly replaces relations in OR-clauses +EXPLAIN (COSTS OFF) +SELECT * FROM emp1 t1 + INNER JOIN emp1 t2 ON t1.id = t2.id + LEFT JOIN emp1 t3 ON t1.code = 1 AND (t2.code = t3.code OR t2.code = 1); + QUERY PLAN +--------------------------------------------------------------------------- + Nested Loop Left Join + Join Filter: ((t2.code = 1) AND ((t2.code = t3.code) OR (t2.code = 1))) + -> Seq Scan on emp1 t2 + -> Materialize + -> Seq Scan on emp1 t3 +(5 rows) + + INSERT INTO emp1 VALUES (1, 1), (2, 1); WITH t1 AS (SELECT * FROM emp1) UPDATE emp1 SET code = t1.code + 1 FROM t1 WHERE t1.id = emp1.id RETURNING emp1.id, emp1.code, t1.code; |