49 #include "utils/fmgroids.h"
56 List **same_input_transnos);
59 Oid aggtransfn,
Oid aggtranstype,
60 int transtypeLen,
bool transtypeByVal,
62 Oid aggserialfn,
Oid aggdeserialfn,
126 int32 aggtranstypmod;
131 List *same_input_transnos;
133 bool resulttypeByVal;
136 bool initValueIsNull;
142 Assert(aggref->agglevelsup == 0);
152 elog(
ERROR,
"cache lookup failed for aggregate %u",
155 aggtransfn = aggform->aggtransfn;
156 aggfinalfn = aggform->aggfinalfn;
157 aggcombinefn = aggform->aggcombinefn;
158 aggserialfn = aggform->aggserialfn;
159 aggdeserialfn = aggform->aggdeserialfn;
160 aggtranstype = aggform->aggtranstype;
161 aggtransspace = aggform->aggtransspace;
175 aggref->aggtranstype = aggtranstype;
200 shareable = (aggform->aggfinalmodify != AGGMODIFY_READ_WRITE);
209 Anum_pg_aggregate_agginitval,
248 root->numOrderedAggs++;
249 root->hasNonPartialAggs =
true;
261 aggtransfn, aggtranstype,
262 transtypeLen, transtypeByVal,
264 aggserialfn, aggdeserialfn,
266 same_input_transnos);
292 if (!
root->hasNonPartialAggs)
299 root->hasNonPartialAggs =
true;
312 root->hasNonSerialAggs =
true;
326 if ((transinfo->
serialfn_oid == F_ARRAY_AGG_SERIALIZE ||
329 root->hasNonSerialAggs =
true;
339 aggref->aggno = aggno;
340 aggref->aggtransno = transno;
380 List **same_input_transnos)
385 *same_input_transnos =
NIL;
401 foreach(lc,
root->agginfos)
411 if (newagg->inputcollid != existingRef->inputcollid ||
412 newagg->aggtranstype != existingRef->aggtranstype ||
413 newagg->aggstar != existingRef->aggstar ||
414 newagg->aggvariadic != existingRef->aggvariadic ||
415 newagg->aggkind != existingRef->aggkind ||
424 newagg->aggtype == existingRef->aggtype &&
425 newagg->aggcollid == existingRef->aggcollid &&
429 *same_input_transnos =
NIL;
441 *same_input_transnos =
lappend_int(*same_input_transnos,
458 Oid aggtransfn,
Oid aggtranstype,
459 int transtypeLen,
bool transtypeByVal,
461 Oid aggserialfn,
Oid aggdeserialfn,
471 foreach(lc, transnos)
514 transtypeByVal, transtypeLen))
563 foreach(lc,
root->aggtransinfos)
667 foreach(lc,
root->agginfos)
#define TextDatumGetCString(d)
#define Assert(condition)
#define OidIsValid(objectId)
bool contain_volatile_functions(Node *clause)
void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root)
bool datumIsEqual(Datum value1, Datum value2, bool typByVal, int typLen)
bool equal(const void *a, const void *b)
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
#define HeapTupleIsValid(tuple)
List * lappend(List *list, void *datum)
List * lappend_int(List *list, int datum)
void list_free(List *list)
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
int32 get_typavgwidth(Oid typid, int32 typmod)
void pfree(void *pointer)
#define ALLOCSET_SMALL_INITSIZE
#define ALLOCSET_DEFAULT_INITSIZE
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
#define expression_tree_walker(n, w, c)
#define DO_AGGSPLIT_SKIPFINAL(as)
#define IsA(nodeptr, _type_)
#define DO_AGGSPLIT_DESERIALIZE(as)
#define DO_AGGSPLIT_COMBINE(as)
#define DO_AGGSPLIT_SERIALIZE(as)
Oid resolve_aggregate_transtype(Oid aggfuncid, Oid aggtranstype, Oid *inputTypes, int numArguments)
bool agg_args_support_sendreceive(Aggref *aggref)
int get_aggregate_argtypes(Aggref *aggref, Oid *inputTypes)
FormData_pg_aggregate * Form_pg_aggregate
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
#define list_nth_node(type, list, n)
void add_function_cost(PlannerInfo *root, Oid funcid, Node *node, QualCost *cost)
static Datum ObjectIdGetDatum(Oid X)
static bool preprocess_aggrefs_walker(Node *node, PlannerInfo *root)
static Datum GetAggInitVal(Datum textInitVal, Oid transtype)
void get_agg_clause_costs(PlannerInfo *root, AggSplit aggsplit, AggClauseCosts *costs)
static int find_compatible_agg(PlannerInfo *root, Aggref *newagg, List **same_input_transnos)
static int find_compatible_trans(PlannerInfo *root, Aggref *newagg, bool shareable, Oid aggtransfn, Oid aggtranstype, int transtypeLen, bool transtypeByVal, Oid aggcombinefn, Oid aggserialfn, Oid aggdeserialfn, Datum initValue, bool initValueIsNull, List *transnos)
static void preprocess_aggref(Aggref *aggref, PlannerInfo *root)
void preprocess_aggrefs(PlannerInfo *root, Node *clause)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)