31#define IS_SRF_CALL(node) \
32 ((IsA(node, FuncExpr) && ((FuncExpr *) (node))->funcretset) || \
33 (IsA(node, OpExpr) && ((OpExpr *) (node))->opretset))
83 foreach(temp, targetlist)
106 foreach(temp, targetlist)
116 var->vartype == tlvar->vartype)
172 if (tle->resjunk && !includeJunk)
226 forboth(lc1, tlist1, lc2, tlist2)
264 if (curColType == NULL)
268 curColType =
lnext(colTypes, curColType);
271 if (curColType != NULL)
298 if (curColColl == NULL)
302 curColColl =
lnext(colCollations, curColColl);
305 if (curColColl != NULL)
324 forboth(ld, dest_tlist, ls, src_tlist)
330 dest_tle->resname = src_tle->resname;
332 dest_tle->resorigtbl = src_tle->resorigtbl;
333 dest_tle->resorigcol = src_tle->resorigcol;
334 dest_tle->resjunk = src_tle->resjunk;
349 foreach(l, targetList)
357 elog(
ERROR,
"ORDER/GROUP BY expression not found in targetlist");
397 foreach(l, sgClauses)
403 result =
lappend(result, sortexpr);
434 elog(
ERROR,
"ORDER/GROUP BY expression not found in list");
472 foreach(glitem, groupClause)
476 groupOperators[colno] = groupcl->
eqop;
481 return groupOperators;
498 foreach(glitem, groupClause)
506 return grpCollations;
523 foreach(glitem, groupClause)
528 grpColIdx[colno++] = tle->
resno;
544 foreach(glitem, groupClause)
564 foreach(glitem, groupClause)
568 if (!groupcl->hashable)
631 foreach(lc, target->
exprs)
640 if (target->sortgrouprefs)
666 if (src->sortgrouprefs)
671 memcpy(dst->sortgrouprefs, src->sortgrouprefs, nbytes);
700 if (target->sortgrouprefs)
705 target->sortgrouprefs = (
Index *)
707 target->sortgrouprefs[nexprs - 1] = sortgroupref;
709 else if (sortgroupref)
715 target->sortgrouprefs[nexprs - 1] = sortgroupref;
780 if (target->sortgrouprefs == NULL)
784 foreach(lc, target->
exprs)
789 if (target->sortgrouprefs[
i])
800 if (expr &&
IsA(expr,
Var))
812 elog(
ERROR,
"ORDER/GROUP BY expression not found in targetlist");
815 elog(
ERROR,
"targetlist item has multiple sortgroupref labels");
883 List **targets,
List **targets_contain_srfs)
887 bool need_extra_projection;
888 List *prev_level_tlist;
901 if (target == input_target)
926 need_extra_projection =
false;
930 foreach(lc, target->
exprs)
958 need_extra_projection =
false;
967 need_extra_projection =
true;
987 if (need_extra_projection)
1009 *targets = *targets_contain_srfs =
NIL;
1010 prev_level_tlist =
NIL;
1047 foreach(lcx, input_srfs)
1061 *targets =
lappend(*targets, ntarget);
1062 *targets_contain_srfs =
lappend_int(*targets_contain_srfs,
1063 (level_srfs !=
NIL));
1066 prev_level_tlist = ntarget->
exprs;
1210 foreach(lc, target->
exprs)
1223 if (target->sortgrouprefs == NULL)
1225 target->sortgrouprefs = (
Index *)
#define Assert(condition)
#define OidIsValid(objectId)
PathTarget * set_pathtarget_cost_width(PlannerInfo *root, PathTarget *target)
bool equal(const void *a, const void *b)
if(TABLE==NULL||TABLE_index==NULL)
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
List * list_copy(const List *oldlist)
List * lappend_int(List *list, int datum)
bool list_member(const List *list, const void *datum)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
void * repalloc(void *pointer, Size size)
void * palloc0(Size size)
Oid exprType(const Node *expr)
Oid exprCollation(const Node *expr)
#define expression_tree_walker(n, w, c)
#define IsA(nodeptr, _type_)
#define get_pathtarget_sortgroupref(target, colno)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define forthree(cell1, list1, cell2, list2, cell3, list3)
#define for_each_cell(cell, lst, initcell)
static ListCell * list_nth_cell(const List *list, int n)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make1_int(x1)
VolatileFunctionStatus has_volatile_expr
List * current_input_srfs
List * input_target_exprs
List * current_input_vars
bool tlist_same_collations(List *tlist, List *colCollations, bool junkOK)
Oid * extract_grouping_ops(List *groupClause)
TargetEntry * tlist_member(Expr *node, List *targetlist)
bool tlist_same_exprs(List *tlist1, List *tlist2)
void apply_tlist_labeling(List *dest_tlist, List *src_tlist)
SortGroupClause * get_sortgroupref_clause_noerr(Index sortref, List *clauses)
SortGroupClause * get_sortgroupref_clause(Index sortref, List *clauses)
void apply_pathtarget_labeling_to_tlist(List *tlist, PathTarget *target)
#define IS_SRF_CALL(node)
bool grouping_is_sortable(List *groupClause)
PathTarget * make_pathtarget_from_tlist(List *tlist)
List * make_tlist_from_pathtarget(PathTarget *target)
PathTarget * copy_pathtarget(PathTarget *src)
static void add_sp_item_to_pathtarget(PathTarget *target, split_pathtarget_item *item)
static bool split_pathtarget_walker(Node *node, split_pathtarget_context *context)
AttrNumber * extract_grouping_cols(List *groupClause, List *tlist)
TargetEntry * get_sortgroupclause_tle(SortGroupClause *sgClause, List *targetList)
void add_new_columns_to_pathtarget(PathTarget *target, List *exprs)
static void add_sp_items_to_pathtarget(PathTarget *target, List *items)
PathTarget * create_empty_pathtarget(void)
List * get_sortgrouplist_exprs(List *sgClauses, List *targetList)
TargetEntry * get_sortgroupref_tle(Index sortref, List *targetList)
List * add_to_flat_tlist(List *tlist, List *exprs)
int count_nonjunk_tlist_entries(List *tlist)
List * get_tlist_exprs(List *tlist, bool includeJunk)
void add_new_column_to_pathtarget(PathTarget *target, Expr *expr)
void split_pathtarget_at_srfs(PlannerInfo *root, PathTarget *target, PathTarget *input_target, List **targets, List **targets_contain_srfs)
bool grouping_is_hashable(List *groupClause)
Oid * extract_grouping_collations(List *groupClause, List *tlist)
static TargetEntry * tlist_member_match_var(Var *var, List *targetlist)
void add_column_to_pathtarget(PathTarget *target, Expr *expr, Index sortgroupref)
Node * get_sortgroupclause_expr(SortGroupClause *sgClause, List *targetList)
bool tlist_same_datatypes(List *tlist, List *colTypes, bool junkOK)