aboutsummaryrefslogtreecommitdiff
path: root/contrib/postgres_fdw/postgres_fdw.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2015-12-08 12:31:03 -0500
committerRobert Haas <rhaas@postgresql.org>2015-12-08 12:31:03 -0500
commit385f337c9f39b21dca96ca4770552a10a6d5af24 (patch)
tree5ca533100c4e832f830540b230ebd0bbe81aed05 /contrib/postgres_fdw/postgres_fdw.c
parentedca44b1525b3d591263d032dc4fe500ea771e0e (diff)
downloadpostgresql-385f337c9f39b21dca96ca4770552a10a6d5af24.tar.gz
postgresql-385f337c9f39b21dca96ca4770552a10a6d5af24.zip
Allow foreign and custom joins to handle EvalPlanQual rechecks.
Commit e7cb7ee14555cc9c5773e2c102efd6371f6f2005 provided basic infrastructure for allowing a foreign data wrapper or custom scan provider to replace a join of one or more tables with a scan. However, this infrastructure failed to take into account the need for possible EvalPlanQual rechecks, and ExecScanFetch would fail an assertion (or just overwrite memory) if such a check was attempted for a plan containing a pushed-down join. To fix, adjust the EPQ machinery to skip some processing steps when scanrelid == 0, making those the responsibility of scan's recheck method, which also has the responsibility in this case of correctly populating the relevant slot. To allow foreign scans to gain control in the right place to make use of this new facility, add a new, optional RecheckForeignScan method. Also, allow a foreign scan to have a child plan, which can be used to correctly populate the slot (or perhaps for something else, but this is the only use currently envisioned). KaiGai Kohei, reviewed by Robert Haas, Etsuro Fujita, and Kyotaro Horiguchi.
Diffstat (limited to 'contrib/postgres_fdw/postgres_fdw.c')
-rw-r--r--contrib/postgres_fdw/postgres_fdw.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index a6ba6723b16..9a014d4dba4 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -214,7 +214,8 @@ static ForeignScan *postgresGetForeignPlan(PlannerInfo *root,
Oid foreigntableid,
ForeignPath *best_path,
List *tlist,
- List *scan_clauses);
+ List *scan_clauses,
+ Plan *outer_plan);
static void postgresBeginForeignScan(ForeignScanState *node, int eflags);
static TupleTableSlot *postgresIterateForeignScan(ForeignScanState *node);
static void postgresReScanForeignScan(ForeignScanState *node);
@@ -535,6 +536,7 @@ postgresGetForeignPaths(PlannerInfo *root,
fpinfo->total_cost,
NIL, /* no pathkeys */
NULL, /* no outer rel either */
+ NULL, /* no extra plan */
NIL); /* no fdw_private list */
add_path(baserel, (Path *) path);
@@ -589,6 +591,7 @@ postgresGetForeignPaths(PlannerInfo *root,
total_cost,
usable_pathkeys,
NULL,
+ NULL,
NIL));
}
@@ -756,6 +759,7 @@ postgresGetForeignPaths(PlannerInfo *root,
total_cost,
NIL, /* no pathkeys */
param_info->ppi_req_outer,
+ NULL,
NIL); /* no fdw_private list */
add_path(baserel, (Path *) path);
}
@@ -771,7 +775,8 @@ postgresGetForeignPlan(PlannerInfo *root,
Oid foreigntableid,
ForeignPath *best_path,
List *tlist,
- List *scan_clauses)
+ List *scan_clauses,
+ Plan *outer_plan)
{
PgFdwRelationInfo *fpinfo = (PgFdwRelationInfo *) baserel->fdw_private;
Index scan_relid = baserel->relid;
@@ -915,7 +920,8 @@ postgresGetForeignPlan(PlannerInfo *root,
params_list,
fdw_private,
NIL, /* no custom tlist */
- remote_exprs);
+ remote_exprs,
+ outer_plan);
}
/*