diff options
| author | Tom Lane | 2023-06-29 16:12:52 +0000 |
|---|---|---|
| committer | Tom Lane | 2023-06-29 16:12:52 +0000 |
| commit | a798660ebe3ff1feb310db13b957c5cda4c8c50d (patch) | |
| tree | 3061c9172724f41cac19a273341f583d932f5656 /src/test | |
| parent | 43af714defa00145981eb542cb71647836b3efa4 (diff) | |
Defend against bogus parameterization of join input paths.
An outer join cannot be formed using an input path that is parameterized
by a value that is supposed to be nulled by the outer join. This is
obviously nonsensical, and it could lead to a bad plan being selected;
although currently it seems that we'll hit various sanity-check
assertions first.
I think that such cases were formerly prevented by the delay_upper_joins
mechanism, but now that that's gone we need an explicit check.
(Perhaps we should avoid generating baserel paths that could
lead to this situation in the first place; but it seems like
having a defense at the join level would be a good idea anyway.)
Richard Guo and Tom Lane, per report from Jaime Casanova
Discussion: https://postgr.es/m/CAJKUy5g2uZRrUDZJ8p-=giwcSHVUn0c9nmdxPSY0jF0Ov8VoEA@mail.gmail.com
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/join.out | 23 | ||||
| -rw-r--r-- | src/test/regress/sql/join.sql | 22 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index 6917faec141..9b8638f286a 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -5064,6 +5064,29 @@ select 1 from (0 rows) -- +-- check a case where we formerly generated invalid parameterized paths +-- +begin; +create temp table t (a int unique); +explain (costs off) +select 1 from t t1 + join lateral (select t1.a from (select 1) foo offset 0) as s1 on true + join + (select 1 from t t2 + inner join (t t3 + left join (t t4 left join t t5 on t4.a = 1) + on t3.a = t4.a) + on false + where t3.a = coalesce(t5.a,1)) as s2 + on true; + QUERY PLAN +-------------------------- + Result + One-Time Filter: false +(2 rows) + +rollback; +-- -- check a case in which a PlaceHolderVar forces join order -- explain (verbose, costs off) diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql index 55080bec9af..3e5032b04dd 100644 --- a/src/test/regress/sql/join.sql +++ b/src/test/regress/sql/join.sql @@ -1752,6 +1752,28 @@ select 1 from lateral (select i4.f1, ss1.n from int8_tbl as i8 limit 1) as ss3; -- +-- check a case where we formerly generated invalid parameterized paths +-- + +begin; + +create temp table t (a int unique); + +explain (costs off) +select 1 from t t1 + join lateral (select t1.a from (select 1) foo offset 0) as s1 on true + join + (select 1 from t t2 + inner join (t t3 + left join (t t4 left join t t5 on t4.a = 1) + on t3.a = t4.a) + on false + where t3.a = coalesce(t5.a,1)) as s2 + on true; + +rollback; + +-- -- check a case in which a PlaceHolderVar forces join order -- |
