Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 28048cb

Browse files
committed
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.
1 parent 307c788 commit 28048cb

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

contrib/file_fdw/file_fdw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ fileGetForeignPaths(PlannerInfo *root,
524524
*/
525525
add_path(baserel, (Path *)
526526
create_foreignscan_path(root, baserel,
527+
NULL, /* default pathtarget */
527528
baserel->rows,
528529
startup_cost,
529530
total_cost,

contrib/postgres_fdw/postgres_fdw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ postgresGetForeignPaths(PlannerInfo *root,
793793
* to estimate cost and size of this path.
794794
*/
795795
path = create_foreignscan_path(root, baserel,
796+
NULL, /* default pathtarget */
796797
fpinfo->rows,
797798
fpinfo->startup_cost,
798799
fpinfo->total_cost,
@@ -964,6 +965,7 @@ postgresGetForeignPaths(PlannerInfo *root,
964965

965966
/* Make the path */
966967
path = create_foreignscan_path(root, baserel,
968+
NULL, /* default pathtarget */
967969
rows,
968970
startup_cost,
969971
total_cost,
@@ -3565,6 +3567,7 @@ add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel,
35653567

35663568
add_path(rel, (Path *)
35673569
create_foreignscan_path(root, rel,
3570+
NULL,
35683571
rows,
35693572
startup_cost,
35703573
total_cost,
@@ -3702,6 +3705,7 @@ postgresGetForeignJoinPaths(PlannerInfo *root,
37023705
*/
37033706
joinpath = create_foreignscan_path(root,
37043707
joinrel,
3708+
NULL, /* default pathtarget */
37053709
rows,
37063710
startup_cost,
37073711
total_cost,

src/backend/optimizer/util/pathnode.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,10 +1819,13 @@ create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel,
18191819
* This function is never called from core Postgres; rather, it's expected
18201820
* to be called by the GetForeignPaths or GetForeignJoinPaths function of
18211821
* a foreign data wrapper. We make the FDW supply all fields of the path,
1822-
* since we do not have any way to calculate them in core.
1822+
* since we do not have any way to calculate them in core. However, there
1823+
* is a sane default for the pathtarget (rel->reltarget), so we let a NULL
1824+
* for "target" select that.
18231825
*/
18241826
ForeignPath *
18251827
create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel,
1828+
PathTarget *target,
18261829
double rows, Cost startup_cost, Cost total_cost,
18271830
List *pathkeys,
18281831
Relids required_outer,
@@ -1833,7 +1836,7 @@ create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel,
18331836

18341837
pathnode->path.pathtype = T_ForeignScan;
18351838
pathnode->path.parent = rel;
1836-
pathnode->path.pathtarget = rel->reltarget;
1839+
pathnode->path.pathtarget = target ? target : rel->reltarget;
18371840
pathnode->path.param_info = get_baserel_parampathinfo(root, rel,
18381841
required_outer);
18391842
pathnode->path.parallel_aware = false;

src/include/optimizer/pathnode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ extern Path *create_ctescan_path(PlannerInfo *root, RelOptInfo *rel,
8787
extern Path *create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel,
8888
Relids required_outer);
8989
extern ForeignPath *create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel,
90+
PathTarget *target,
9091
double rows, Cost startup_cost, Cost total_cost,
9192
List *pathkeys,
9293
Relids required_outer,

0 commit comments

Comments
 (0)