MCPcopy Create free account
hub / github.com/apache/cloudberry / postgresGetForeignPaths

Function postgresGetForeignPaths

contrib/postgres_fdw/postgres_fdw.c:1011–1214  ·  view source on GitHub ↗

* postgresGetForeignPaths * Create possible scan paths for a scan on the foreign table */

Source from the content-addressed store, hash-verified

1009 * Create possible scan paths for a scan on the foreign table
1010 */
1011static void
1012postgresGetForeignPaths(PlannerInfo *root,
1013 RelOptInfo *baserel,
1014 Oid foreigntableid)
1015{
1016 PgFdwRelationInfo *fpinfo = (PgFdwRelationInfo *) baserel->fdw_private;
1017 ForeignPath *path;
1018 List *ppi_list;
1019 ListCell *lc;
1020
1021 /*
1022 * Create simplest ForeignScan path node and add it to baserel. This path
1023 * corresponds to SeqScan path of regular tables (though depending on what
1024 * baserestrict conditions we were able to send to remote, there might
1025 * actually be an indexscan happening there). We already did all the work
1026 * to estimate cost and size of this path.
1027 *
1028 * Although this path uses no join clauses, it could still have required
1029 * parameterization due to LATERAL refs in its tlist.
1030 */
1031 path = create_foreignscan_path(root, baserel,
1032 NULL, /* default pathtarget */
1033 fpinfo->rows,
1034 fpinfo->startup_cost,
1035 fpinfo->total_cost,
1036 NIL, /* no pathkeys */
1037 baserel->lateral_relids,
1038 NULL, /* no extra plan */
1039 NIL); /* no fdw_private list */
1040 add_path(baserel, (Path *) path, root);
1041
1042 /* Add paths with pathkeys */
1043 add_paths_with_pathkeys_for_rel(root, baserel, NULL);
1044
1045 /*
1046 * If we're not using remote estimates, stop here. We have no way to
1047 * estimate whether any join clauses would be worth sending across, so
1048 * don't bother building parameterized paths.
1049 */
1050 if (!fpinfo->use_remote_estimate)
1051 return;
1052
1053 /*
1054 * Thumb through all join clauses for the rel to identify which outer
1055 * relations could supply one or more safe-to-send-to-remote join clauses.
1056 * We'll build a parameterized path for each such outer relation.
1057 *
1058 * It's convenient to manage this by representing each candidate outer
1059 * relation by the ParamPathInfo node for it. We can then use the
1060 * ppi_clauses list in the ParamPathInfo node directly as a list of the
1061 * interesting join clauses for that rel. This takes care of the
1062 * possibility that there are multiple safe join clauses for such a rel,
1063 * and also ensures that we account for unsafe join clauses that we'll
1064 * still have to enforce locally (since the parameterized-path machinery
1065 * insists that we handle all movable clauses).
1066 */
1067 ppi_list = NIL;
1068 foreach(lc, baserel->joininfo)

Callers

nothing calls this directly

Calls 14

create_foreignscan_pathFunction · 0.85
add_pathFunction · 0.85
is_foreign_exprFunction · 0.85
bms_unionFunction · 0.85
bms_del_memberFunction · 0.85
bms_is_emptyFunction · 0.85
list_append_unique_ptrFunction · 0.85
lappendFunction · 0.85

Tested by

no test coverage detected