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

Function postgresGetForeignUpperPaths

contrib/postgres_fdw/postgres_fdw.c:6413–6457  ·  view source on GitHub ↗

* postgresGetForeignUpperPaths * Add paths for post-join operations like aggregation, grouping etc. if * corresponding operations are safe to push down. */

Source from the content-addressed store, hash-verified

6411 * corresponding operations are safe to push down.
6412 */
6413static void
6414postgresGetForeignUpperPaths(PlannerInfo *root, UpperRelationKind stage,
6415 RelOptInfo *input_rel, RelOptInfo *output_rel,
6416 void *extra)
6417{
6418 PgFdwRelationInfo *fpinfo;
6419
6420 /*
6421 * If input rel is not safe to pushdown, then simply return as we cannot
6422 * perform any post-join operations on the foreign server.
6423 */
6424 if (!input_rel->fdw_private ||
6425 !((PgFdwRelationInfo *) input_rel->fdw_private)->pushdown_safe)
6426 return;
6427
6428 /* Ignore stages we don't support; and skip any duplicate calls. */
6429 if ((stage != UPPERREL_GROUP_AGG &&
6430 stage != UPPERREL_ORDERED &&
6431 stage != UPPERREL_FINAL) ||
6432 output_rel->fdw_private)
6433 return;
6434
6435 fpinfo = (PgFdwRelationInfo *) palloc0(sizeof(PgFdwRelationInfo));
6436 fpinfo->pushdown_safe = false;
6437 fpinfo->stage = stage;
6438 output_rel->fdw_private = fpinfo;
6439
6440 switch (stage)
6441 {
6442 case UPPERREL_GROUP_AGG:
6443 add_foreign_grouping_paths(root, input_rel, output_rel,
6444 (GroupPathExtraData *) extra);
6445 break;
6446 case UPPERREL_ORDERED:
6447 add_foreign_ordered_paths(root, input_rel, output_rel);
6448 break;
6449 case UPPERREL_FINAL:
6450 add_foreign_final_paths(root, input_rel, output_rel,
6451 (FinalPathExtraData *) extra);
6452 break;
6453 default:
6454 elog(ERROR, "unexpected upper relation: %d", (int) stage);
6455 break;
6456 }
6457}
6458
6459/*
6460 * add_foreign_grouping_paths

Callers

nothing calls this directly

Calls 4

add_foreign_final_pathsFunction · 0.85
palloc0Function · 0.50

Tested by

no test coverage detected