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

Function postgresGetForeignPlan

contrib/postgres_fdw/postgres_fdw.c:1220–1434  ·  view source on GitHub ↗

* postgresGetForeignPlan * Create ForeignScan plan node which implements selected best path */

Source from the content-addressed store, hash-verified

1218 * Create ForeignScan plan node which implements selected best path
1219 */
1220static ForeignScan *
1221postgresGetForeignPlan(PlannerInfo *root,
1222 RelOptInfo *foreignrel,
1223 Oid foreigntableid,
1224 ForeignPath *best_path,
1225 List *tlist,
1226 List *scan_clauses,
1227 Plan *outer_plan)
1228{
1229 PgFdwRelationInfo *fpinfo = (PgFdwRelationInfo *) foreignrel->fdw_private;
1230 Index scan_relid;
1231 List *fdw_private;
1232 List *remote_exprs = NIL;
1233 List *local_exprs = NIL;
1234 List *params_list = NIL;
1235 List *fdw_scan_tlist = NIL;
1236 List *fdw_recheck_quals = NIL;
1237 List *retrieved_attrs;
1238 StringInfoData sql;
1239 bool has_final_sort = false;
1240 bool has_limit = false;
1241 ListCell *lc;
1242
1243 /*
1244 * Get FDW private data created by postgresGetForeignUpperPaths(), if any.
1245 */
1246 if (best_path->fdw_private)
1247 {
1248 has_final_sort = intVal(list_nth(best_path->fdw_private,
1249 FdwPathPrivateHasFinalSort));
1250 has_limit = intVal(list_nth(best_path->fdw_private,
1251 FdwPathPrivateHasLimit));
1252 }
1253
1254 if (IS_SIMPLE_REL(foreignrel))
1255 {
1256 /*
1257 * For base relations, set scan_relid as the relid of the relation.
1258 */
1259 scan_relid = foreignrel->relid;
1260
1261 /*
1262 * In a base-relation scan, we must apply the given scan_clauses.
1263 *
1264 * Separate the scan_clauses into those that can be executed remotely
1265 * and those that can't. baserestrictinfo clauses that were
1266 * previously determined to be safe or unsafe by classifyConditions
1267 * are found in fpinfo->remote_conds and fpinfo->local_conds. Anything
1268 * else in the scan_clauses list will be a join clause, which we have
1269 * to check for remote-safety.
1270 *
1271 * Note: the join clauses we see here should be the exact same ones
1272 * previously examined by postgresGetForeignPaths. Possibly it'd be
1273 * worth passing forward the classification work done then, rather
1274 * than repeating it here.
1275 *
1276 * This code must match "extract_actual_clauses(scan_clauses, false)"
1277 * except for the additional decision about remote versus local

Callers

nothing calls this directly

Calls 14

list_nthFunction · 0.85
list_member_ptrFunction · 0.85
lappendFunction · 0.85
is_foreign_exprFunction · 0.85
extract_actual_clausesFunction · 0.85
build_tlist_to_deparseFunction · 0.85
list_deleteFunction · 0.85
change_plan_targetlistFunction · 0.85
initStringInfoFunction · 0.85
deparseSelectStmtForRelFunction · 0.85
makeStringFunction · 0.85
makeIntegerFunction · 0.85

Tested by

no test coverage detected