32#define IS_SRF_CALL(node) \
33 ((IsA(node, FuncExpr) && ((FuncExpr *) (node))->funcretset) || \
34 (IsA(node, OpExpr) && ((OpExpr *) (node))->opretset))
70 bool is_grouping_target);
92 foreach(
temp, targetlist)
115 foreach(
temp, targetlist)
125 var->vartype ==
tlvar->vartype)
358 foreach(l, targetList)
366 elog(
ERROR,
"ORDER/GROUP BY expression not found in targetlist");
443 elog(
ERROR,
"ORDER/GROUP BY expression not found in list");
481 foreach(
glitem, groupClause)
507 foreach(
glitem, groupClause)
532 foreach(
glitem, groupClause)
553 foreach(
glitem, groupClause)
573 foreach(
glitem, groupClause)
614 target->sortgrouprefs[
i] =
tle->ressortgroupref;
649 if (target->sortgrouprefs)
650 tle->ressortgroupref = target->sortgrouprefs[
i];
675 if (src->sortgrouprefs)
680 memcpy(
dst->sortgrouprefs, src->sortgrouprefs, nbytes);
709 if (target->sortgrouprefs)
714 target->sortgrouprefs = (
Index *)
716 target->sortgrouprefs[
nexprs - 1] = sortgroupref;
718 else if (sortgroupref)
724 target->sortgrouprefs[
nexprs - 1] = sortgroupref;
789 if (target->sortgrouprefs ==
NULL)
798 if (target->sortgrouprefs[
i])
809 if (expr &&
IsA(expr,
Var))
821 elog(
ERROR,
"ORDER/GROUP BY expression not found in targetlist");
822 if (
tle->ressortgroupref != 0 &&
823 tle->ressortgroupref != target->sortgrouprefs[
i])
824 elog(
ERROR,
"targetlist item has multiple sortgroupref labels");
826 tle->ressortgroupref = target->sortgrouprefs[
i];
945 bool is_grouping_target)
1130 (level_srfs !=
NIL));
1308 if (target->sortgrouprefs ==
NULL)
1310 target->sortgrouprefs = (
Index *)
Bitmapset * bms_make_singleton(int x)
#define Assert(condition)
#define OidIsValid(objectId)
PathTarget * set_pathtarget_cost_width(PlannerInfo *root, PathTarget *target)
bool equal(const void *a, const void *b)
#define palloc_object(type)
#define palloc_array(type, count)
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)
Node * remove_nulling_relids(Node *node, const Bitmapset *removable_relids, const Bitmapset *except_relids)
VolatileFunctionStatus has_volatile_expr
List * current_input_srfs
List * input_target_exprs
List * current_input_vars
void split_pathtarget_at_srfs_grouping(PlannerInfo *root, PathTarget *target, PathTarget *input_target, List **targets, List **targets_contain_srfs)
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)
static void split_pathtarget_at_srfs_extended(PlannerInfo *root, PathTarget *target, PathTarget *input_target, List **targets, List **targets_contain_srfs, bool is_grouping_target)
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)