Allow FDWs to push down quals without breaking EvalPlanQual rechecks.
Robert Haas <rhaas@postgresql.org>
Allow FDWs to push down quals without breaking EvalPlanQual rechecks. This fixes a long-standing bug which was discovered while investigating the interaction between the new join pushdown code and the EvalPlanQual machinery: if a ForeignScan appears on the inner side of a paramaterized nestloop, an EPQ recheck would re-return the original tuple even if it no longer satisfied the pushed-down quals due to changed parameter values. This fix adds a new member to ForeignScan and ForeignScanState and a new argument to make_foreignscan, and requires changes to FDWs which push down quals to populate that new argument with a list of quals they have chosen to push down. Therefore, I'm only back-patching to 9.5, even though the bug is not new in 9.5. Etsuro Fujita, reviewed by me and by Kyotaro Horiguchi.
Files
| Path | Change | +/− |
|---|---|---|
| contrib/file_fdw/file_fdw.c | modified | +2 −1 |
| contrib/postgres_fdw/postgres_fdw.c | modified | +11 −3 |
| doc/src/sgml/fdwhandler.sgml | modified | +9 −0 |
| src/backend/executor/nodeForeignscan.c | modified | +17 −2 |
| src/backend/nodes/copyfuncs.c | modified | +1 −0 |
| src/backend/nodes/outfuncs.c | modified | +1 −0 |
| src/backend/optimizer/plan/createplan.c | modified | +6 −1 |
| src/backend/optimizer/plan/setrefs.c | modified | +3 −1 |
| src/backend/optimizer/plan/subselect.c | modified | +12 −4 |
| src/include/nodes/execnodes.h | modified | +1 −0 |
| src/include/nodes/plannodes.h | modified | +6 −0 |
| src/include/optimizer/planmain.h | modified | +1 −1 |