diff options
| author | Tom Lane | 2014-01-30 19:51:16 +0000 |
|---|---|---|
| committer | Tom Lane | 2014-01-30 19:51:16 +0000 |
| commit | 043f6ff05d0a5140dfe25faf277ec9f1d7169005 (patch) | |
| tree | 27542bd423573ef86ba25c4c3c4188fc21169ea7 /src/test | |
| parent | c29a6dd54860082153ec7fedb603a4c2c37b1445 (diff) | |
Fix bogus handling of "postponed" lateral quals.
When pulling a "postponed" qual from a LATERAL subquery up into the quals
of an outer join, we must make sure that the postponed qual is included
in those seen by make_outerjoininfo(). Otherwise we might compute a
too-small min_lefthand or min_righthand for the outer join, leading to
"JOIN qualification cannot refer to other relations" failures from
distribute_qual_to_rels. Subtler errors in the created plan seem possible,
too, if the extra qual would only affect join ordering constraints.
Per bug #9041 from David Leverton. Back-patch to 9.3.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/join.out | 22 | ||||
| -rw-r--r-- | src/test/regress/sql/join.sql | 8 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index 74bc8ead26c..ec64bbe7b99 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -4060,6 +4060,28 @@ select c.*,a.*,ss1.q1,ss2.q1,ss3.* from Output: i.f1 (34 rows) +-- check processing of postponed quals (bug #9041) +explain (verbose, costs off) +select * from + (select 1 as x) x cross join (select 2 as y) y + left join lateral ( + select * from (select 3 as z) z where z.z = x.x + ) zz on zz.z = y.y; + QUERY PLAN +---------------------------------------------- + Nested Loop Left Join + Output: (1), (2), (3) + Join Filter: (((3) = (1)) AND ((3) = (2))) + -> Nested Loop + Output: (1), (2) + -> Result + Output: 1 + -> Result + Output: 2 + -> Result + Output: 3 +(11 rows) + -- test some error cases where LATERAL should have been used but wasn't select f1,g from int4_tbl a, (select f1 as g) ss; ERROR: column "f1" does not exist diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql index 409e0b13d62..f45aa145ade 100644 --- a/src/test/regress/sql/join.sql +++ b/src/test/regress/sql/join.sql @@ -1134,6 +1134,14 @@ select c.*,a.*,ss1.q1,ss2.q1,ss3.* from ) on c.q2 = ss2.q1, lateral (select * from int4_tbl i where ss2.y > f1) ss3; +-- check processing of postponed quals (bug #9041) +explain (verbose, costs off) +select * from + (select 1 as x) x cross join (select 2 as y) y + left join lateral ( + select * from (select 3 as z) z where z.z = x.x + ) zz on zz.z = y.y; + -- test some error cases where LATERAL should have been used but wasn't select f1,g from int4_tbl a, (select f1 as g) ss; select f1,g from int4_tbl a, (select a.f1 as g) ss; |
