Fix "wrong varnullingrels" for subquery nestloop parameters.
Tom Lane <tgl@sss.pgh.pa.us>
Fix "wrong varnullingrels" for subquery nestloop parameters. If we apply outer join identity 3 when relation C is a subquery having lateral references to relation B, then the lateral references within C continue to bear the original syntactically-correct varnullingrels marks, but that won't match what is available from the outer side of the nestloop. Compensate for that in process_subquery_nestloop_params(). This is a slightly hacky fix, but we certainly don't want to re-plan C in toto for each possible outer join order, so there's not a lot of better alternatives. Richard Guo and Tom Lane, per report from Markus Winand Discussion: https://postgr.es/m/DFBB2D25-DE97-49CA-A60E-07C881EA59A7@winand.at
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/plan/setrefs.c | modified | +5 −3 |
| src/backend/optimizer/util/paramassign.c | modified | +29 −7 |
| src/test/regress/expected/join.out | modified | +18 −0 |
| src/test/regress/sql/join.sql | modified | +7 −0 |
Discussion
- ERROR: wrong varnullingrels (b 3) (expected (b)) for Var 2/1 13 messages · 2023-05-30 → 2023-06-19