foreach(lc, restrictinfolist) { List *targetcolumns; RestrictInfo *node = (RestrictInfo *) lfirst(lc); targetcolumns = pull_var_clause((Node *) node->clause, PVC_RECURSE_AGGREGATES, PVC_RECURSE_PLACEHOLDERS); columns = list_union(columns, targetcolumns); }
/* * build_base_rel_tlists * Add targetlist entries for each var needed in the query's final tlist * to the appropriate base relations. * * We mark such vars as needed by "relation 0" to ensure that they will * propagate up through all join plan steps. */ void build_base_rel_tlists(PlannerInfo *root, List *final_tlist) { List *tlist_vars = pull_var_clause((Node *) final_tlist, PVC_INCLUDE_PLACEHOLDERS); if (tlist_vars != NIL) { add_vars_to_targetlist(root, tlist_vars, bms_make_singleton(0)); list_free(tlist_vars); } }
/* * initialize_rel_nodes-- * Creates rel nodes for every relation mentioned in the target list * 'tlist' (if a node hasn't already been created) and adds them to * *query-relation-list*. Creates targetlist entries for each member of * 'tlist' and adds them to the tlist field of the appropriate rel node. * * Returns nothing. */ void initialize_base_rels_list(Query *root, List *tlist) { List *tlist_vars = NIL; List *l = NIL; List *tvar = NIL; foreach (l, tlist) { TargetEntry *entry = (TargetEntry *) lfirst(l); tlist_vars = append(tlist_vars, pull_var_clause(entry->expr)); }
/* * The list of needed columns (represented by their respective vars) * is pulled from: * - the targetcolumns * - the restrictinfo */ List * extractColumns(List *reltargetlist, List *restrictinfolist) { ListCell *lc; List *columns = NULL; int i = 0; foreach(lc, reltargetlist) { List *targetcolumns; Node *node = (Node *) lfirst(lc); targetcolumns = pull_var_clause(node, PVC_RECURSE_AGGREGATES, PVC_RECURSE_PLACEHOLDERS); columns = list_union(columns, targetcolumns); i++; }