Teach planner about some cases where a restriction clause can be
Tom Lane <tgl@sss.pgh.pa.us>
Teach planner about some cases where a restriction clause can be propagated inside an outer join. In particular, given LEFT JOIN ON (A = B) WHERE A = constant, we cannot conclude that B = constant at the top level (B might be null instead), but we can nonetheless put a restriction B = constant into the quals for B's relation, since no inner-side rows not meeting that condition can contribute to the final result. Similarly, given FULL JOIN USING (J) WHERE J = constant, we can't directly conclude that either input J variable = constant, but it's OK to push such quals into each input rel. Per recent gripe from Kim Bisgaard. Along the way, remove 'valid_everywhere' flag from RestrictInfo, as on closer analysis it was not being used for anything, and was defined backwards anyway.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/nodes/copyfuncs.c | modified | +1 −2 |
| src/backend/nodes/equalfuncs.c | modified | +1 −2 |
| src/backend/nodes/outfuncs.c | modified | +5 −2 |
| src/backend/optimizer/path/indxpath.c | modified | +7 −7 |
| src/backend/optimizer/path/orindxpath.c | modified | +4 −8 |
| src/backend/optimizer/path/pathkeys.c | modified | +288 −3 |
| src/backend/optimizer/plan/createplan.c | modified | +2 −3 |
| src/backend/optimizer/plan/initsplan.c | modified | +75 −36 |
| src/backend/optimizer/plan/planmain.c | modified | +4 −1 |
| src/backend/optimizer/plan/planner.c | modified | +10 −7 |
| src/backend/optimizer/util/restrictinfo.c | modified | +14 −32 |
| src/include/nodes/relation.h | modified | +11 −7 |
| src/include/optimizer/restrictinfo.h | modified | +2 −4 |