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.
Branch
------
REL9_5_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/5043193b78919a1bd144563aadc2f7f726549913
Modified Files
--------------
contrib/file_fdw/file_fdw.c | 3 ++-
contrib/postgres_fdw/postgres_fdw.c | 14 +++++++++++---
doc/src/sgml/fdwhandler.sgml | 9 +++++++++
src/backend/executor/nodeForeignscan.c | 19 +++++++++++++++++--
src/backend/nodes/copyfuncs.c | 1 +
src/backend/nodes/outfuncs.c | 1 +
src/backend/optimizer/plan/createplan.c | 7 ++++++-
src/backend/optimizer/plan/setrefs.c | 4 +++-
src/backend/optimizer/plan/subselect.c | 16 ++++++++++++----
src/include/nodes/execnodes.h | 1 +
src/include/nodes/plannodes.h | 6 ++++++
src/include/optimizer/planmain.h | 2 +-
12 files changed, 70 insertions(+), 13 deletions(-)