diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-03-14 17:31:28 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-03-14 17:31:28 -0400 |
commit | 28048cbaa285b8ac46940e4b39f985d9885fc698 (patch) | |
tree | 419821d979318f9474d05d52b619fba5ad568d32 /src | |
parent | 307c78852f516042cebacaed411a0391bfeb2129 (diff) | |
download | postgresql-28048cbaa285b8ac46940e4b39f985d9885fc698.tar.gz postgresql-28048cbaa285b8ac46940e4b39f985d9885fc698.zip |
Allow callers of create_foreignscan_path to specify nondefault PathTarget.
Although the default choice of rel->reltarget should typically be
sufficient for scan or join paths, it's not at all sufficient for the
purposes PathTargets were invented for; in particular not for
upper-relation Paths. So break API compatibility by adding a PathTarget
argument to create_foreignscan_path(). To ease updating of existing
code, accept a NULL value of the argument as selecting rel->reltarget.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/util/pathnode.c | 7 | ||||
-rw-r--r-- | src/include/optimizer/pathnode.h | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 8f089c59884..675e47cdd01 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -1819,10 +1819,13 @@ create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, * This function is never called from core Postgres; rather, it's expected * to be called by the GetForeignPaths or GetForeignJoinPaths function of * a foreign data wrapper. We make the FDW supply all fields of the path, - * since we do not have any way to calculate them in core. + * since we do not have any way to calculate them in core. However, there + * is a sane default for the pathtarget (rel->reltarget), so we let a NULL + * for "target" select that. */ ForeignPath * create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel, + PathTarget *target, double rows, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer, @@ -1833,7 +1836,7 @@ create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel, pathnode->path.pathtype = T_ForeignScan; pathnode->path.parent = rel; - pathnode->path.pathtarget = rel->reltarget; + pathnode->path.pathtarget = target ? target : rel->reltarget; pathnode->path.param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->path.parallel_aware = false; diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 3007adb8c2d..d1eb22f27a4 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -87,6 +87,7 @@ extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, extern Path *create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer); extern ForeignPath *create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel, + PathTarget *target, double rows, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer, |