298#define HASHAGG_PARTITION_FACTOR 1.50
299#define HASHAGG_MIN_PARTITIONS 4
300#define HASHAGG_MAX_PARTITIONS 1024
308#define HASHAGG_READ_BUFFER_SIZE BLCKSZ
309#define HASHAGG_WRITE_BUFFER_SIZE BLCKSZ
317#define HASHAGG_HLL_BIT_WIDTH 5
322#define CHUNKHDRSZ sizeof(MemoryChunk)
414 double hashentrysize,
433 int64 input_tuples,
double input_card,
438 double hashentrysize);
529 sortnode->sortColIdx,
530 sortnode->sortOperators,
531 sortnode->collations,
532 sortnode->nullsFirst,
681 for (setno = 0; setno <
numReset; setno++)
687 for (transno = 0; transno <
numTrans; transno++)
726 for (
i = 1;
i <= numTransInputs;
i++)
979 if (numDistinctCols == 0 ||
992 for (
i = 0;
i < numTransInputs;
i++)
1000 if (numDistinctCols > 0)
1052 bool anynull =
false;
1073 &fcinfo->args[
i].isnull);
1074 anynull |= fcinfo->args[
i].isnull;
1094 fcinfo->args[0].value =
1102 for (;
i < numFinalArgs;
i++)
1104 fcinfo->args[
i].value = (
Datum) 0;
1105 fcinfo->args[
i].isnull =
true;
1109 if (fcinfo->flinfo->fn_strict && anynull)
1255 aggstate->grouped_cols = grouped_cols;
1266 else if (
aggstate->all_grouped_cols)
1307 for (
int transno = 0; transno <
aggstate->numtrans; transno++)
1348 for (aggno = 0; aggno <
aggstate->numaggs; aggno++)
1351 int transno = peragg->
transno;
1411 for (
int i = 0;
i <
agg->numCols;
i++)
1471 for (setno = 0; setno <
aggstate->num_hashes; ++setno)
1490#ifdef USE_INJECTION_POINTS
1501 aggstate->hash_ngroups_current = 0;
1514 Size additionalsize;
1534 perhash->
aggnode->grpCollations,
1590 aggstate->max_colno_needed = colno;
1614 if (
aggstate->phases[0].grouped_cols)
1682 perhash->
aggnode->grpOperators,
1720 if (transitionSpace > 0)
1784 aggstate->ss.ps.outeropsfixed =
true;
1792 aggstate->ss.ps.outerops = outerops;
1810 int *num_partitions)
1819 if (num_partitions !=
NULL)
1820 *num_partitions = 0;
1821 *mem_limit = hash_mem_limit;
1835 if (num_partitions !=
NULL)
1836 *num_partitions = npartitions;
1850 *mem_limit = hash_mem_limit * 0.75;
1852 if (*mem_limit > hashentrysize)
1878#ifdef USE_INJECTION_POINTS
1893 if (
aggstate->hash_ngroups_current > 0 &&
1921 aggstate->hash_ever_spilled =
true;
1927 for (
int setno = 0; setno <
aggstate->num_hashes; setno++)
1987 if (
aggstate->hash_ngroups_current > 0)
2018 "HashAgg meta context",
2046 "HashAgg hashed tuples",
2159 for (transno = 0; transno <
aggstate->numtrans; transno++)
2190 for (setno = 0; setno <
aggstate->num_hashes; setno++)
2307 econtext =
aggstate->ss.ps.ps_ExprContext;
2342 if (
aggstate->projected_set >= 0 &&
2364 if (
aggstate->input_done ==
true &&
2401 if (
aggstate->projected_set >= 0 &&
2714 for (
int setno = 0; setno <
aggstate->num_hashes; setno++)
2717 aggstate->hash_ngroups_current = 0;
2766 aggstate->tmpcontext->ecxt_outertuple,
2841 while (result ==
NULL)
2877 econtext =
aggstate->ss.ps.ps_ExprContext;
2945 firstSlot->tts_tupleDescriptor->natts *
sizeof(
bool));
2995#ifdef USE_INJECTION_POINTS
3008 for (
int i = 0;
i < npartitions;
i++)
3012 if (
spill->shift < 32)
3013 spill->mask = (npartitions - 1) <<
spill->shift;
3016 spill->npartitions = npartitions;
3018 for (
int i = 0;
i < npartitions;
i++)
3047 for (
int i = 0;
i <
spillslot->tts_tupleDescriptor->natts;
i++)
3064 if (
spill->shift < 32)
3100 int64 input_tuples,
double input_card,
int used_bits)
3104 batch->setno = setno;
3105 batch->used_bits = used_bits;
3106 batch->input_tape = input_tape;
3107 batch->input_tuples = input_tuples;
3108 batch->input_card = input_card;
3132 errmsg_internal(
"unexpected EOF for tape %p: requested %zu bytes, read %zu bytes",
3141 errmsg_internal(
"unexpected EOF for tape %p: requested %zu bytes, read %zu bytes",
3145 tuple->
t_len = t_len;
3148 (
char *) tuple +
sizeof(
uint32),
3153 errmsg_internal(
"unexpected EOF for tape %p: requested %zu bytes, read %zu bytes",
3174 for (setno = 0; setno <
aggstate->num_hashes; setno++)
3204 int used_bits = 32 -
spill->shift;
3206 if (
spill->npartitions == 0)
3209 for (
i = 0;
i <
spill->npartitions;
i++)
3216 if (
spill->ntuples[
i] == 0)
3248 for (setno = 0; setno <
aggstate->num_hashes; setno++)
3352 foreach(l, node->
chain)
3420 aggstate->ss.ps.outeropsset =
true;
3449 if (
aggstate->ss.ps.outeropsfixed &&
3451 aggstate->ss.ps.outeropsfixed =
false;
3524 Assert(phase <= 1 || sortnode);
3605 for (
int k = 0; k <
phasedata->numsets; k++)
3607 int length =
phasedata->gset_lengths[k];
3621 aggnode->grpOperators,
3622 aggnode->grpCollations,
3634 aggnode->grpOperators,
3635 aggnode->grpCollations,
3657 econtext =
aggstate->ss.ps.ps_ExprContext;
3669 pergroups =
aggstate->all_pergroups;
3696 aggstate->hash_pergroup = pergroups;
3708 for (
int k = 0; k <
aggstate->num_hashes; k++)
3714 &
aggstate->hash_planned_partitions);
3769 Assert(aggref->agglevelsup == 0);
3773 peragg = &
peraggs[aggref->aggno];
3780 peragg->
transno = aggref->aggtransno;
3786 elog(
ERROR,
"cache lookup failed for aggregate %u",
3799 aggtranstype = aggref->aggtranstype;
3828 elog(
ERROR,
"serialfunc not provided for serialization aggregation");
3829 serialfn_oid =
aggform->aggserialfn;
3839 elog(
ERROR,
"deserialfunc not provided for deserialization aggregation");
3840 deserialfn_oid =
aggform->aggdeserialfn;
3851 elog(
ERROR,
"cache lookup failed for function %u",
3916 aggref->inputcollid,
3937 bool initValueIsNull;
3947 transfn_oid =
aggform->aggcombinefn;
3951 elog(
ERROR,
"combinefn not set for aggregate function");
3954 transfn_oid =
aggform->aggtransfn;
3969 if (initValueIsNull)
3988 aggref, transfn_oid, aggtranstype,
3989 serialfn_oid, deserialfn_oid,
4002 errmsg(
"combine function with transition type %s must not be declared STRICT",
4014 aggref, transfn_oid, aggtranstype,
4015 serialfn_oid, deserialfn_oid,
4036 errmsg(
"aggregate %u needs to have compatible input type and transition type",
4059 errmsg(
"aggregate function calls cannot be nested")));
4134 Oid transfn_oid,
Oid aggtranstype,
4149 int numDistinctCols;
4153 pertrans->
aggref = aggref;
4180 aggref->aggvariadic,
4182 aggref->inputcollid,
4254 numSortCols = numDistinctCols = 0;
4260 numSortCols = numDistinctCols = 0;
4274 numDistinctCols = 0;
4286 if (numSortCols > 0 || aggref->
aggfilter)
4294 if (numSortCols > 0)
4312 else if (numDistinctCols > 0)
4328 (
bool *)
palloc(numSortCols *
sizeof(
bool));
4352 Assert(numArguments > 0);
4355 ops =
palloc(numDistinctCols *
sizeof(
Oid));
4362 if (numDistinctCols == 1)
4440 for (transno = 0; transno < node->
numtrans; transno++)
4502 for (transno = 0; transno < node->
numtrans; transno++)
4665 return curperagg->
aggref;
4668 curpertrans =
aggstate->curpertrans;
4671 return curpertrans->
aggref;
4693 return aggstate->tmpcontext->ecxt_per_tuple_memory;
4728 curpertrans =
aggstate->curpertrans;
4765 elog(
ERROR,
"aggregate function cannot register a callback in this context");
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
int bms_next_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_del_member(Bitmapset *a, int x)
void bms_free(Bitmapset *a)
int bms_num_members(const Bitmapset *a)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_copy(const Bitmapset *a)
#define TextDatumGetCString(d)
MemoryContext BumpContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
#define Assert(condition)
#define MemSet(start, val, len)
#define OidIsValid(objectId)
Datum datumCopy(Datum value, bool typByVal, int typLen)
int errcode_for_file_access(void)
int errcode(int sqlerrcode)
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
void ExecReScan(PlanState *node)
Datum ExecAggCopyTransValue(AggState *aggstate, AggStatePerTrans pertrans, Datum newValue, bool newValueIsNull, Datum oldValue, bool oldValueIsNull)
ExprState * ExecInitQual(List *qual, PlanState *parent)
List * ExecInitExprList(List *nodes, PlanState *parent)
ExprState * ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, bool doSort, bool doHash, bool nullcheck)
ExprState * execTuplesMatchPrepare(TupleDesc desc, int numCols, const AttrNumber *keyColIdx, const Oid *eqOperators, const Oid *collations, PlanState *parent)
void execTuplesHashPrepare(int numCols, const Oid *eqOperators, Oid **eqFuncOids, FmgrInfo **hashFunctions)
TupleHashTable BuildTupleHashTable(PlanState *parent, TupleDesc inputDesc, const TupleTableSlotOps *inputOps, int numCols, AttrNumber *keyColIdx, const Oid *eqfuncoids, FmgrInfo *hashfunctions, Oid *collations, double nelements, Size additionalsize, MemoryContext metacxt, MemoryContext tuplescxt, MemoryContext tempcxt, bool use_variable_hash_iv)
TupleHashEntry LookupTupleHashEntryHash(TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 hash)
TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, bool *isnew, uint32 *hash)
void ResetTupleHashTable(TupleHashTable hashtable)
void ExecEndNode(PlanState *node)
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
const TupleTableSlotOps TTSOpsVirtual
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
MinimalTuple ExecFetchSlotMinimalTuple(TupleTableSlot *slot, bool *shouldFree)
TupleTableSlot * ExecStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
const TupleTableSlotOps TTSOpsMinimalTuple
TupleTableSlot * ExecAllocTableSlot(List **tupleTable, TupleDesc desc, const TupleTableSlotOps *tts_ops, uint16 flags)
TupleTableSlot * ExecStoreAllNullTuple(TupleTableSlot *slot)
TupleDesc ExecTypeFromTL(List *targetList)
void ExecForceStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
TupleDesc ExecGetResultType(PlanState *planstate)
void ReScanExprContext(ExprContext *econtext)
void ExecCreateScanSlotFromOuterPlan(EState *estate, ScanState *scanstate, const TupleTableSlotOps *tts_ops)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
void RegisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
ExprContext * CreateWorkExprContext(EState *estate)
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
#define InstrCountFiltered1(node, delta)
#define outerPlanState(node)
#define ScanTupleHashTable(htable, iter)
#define ResetTupleHashIterator(htable, iter)
struct AggStatePerGroupData * AggStatePerGroup
static MinimalTuple TupleHashEntryGetTuple(TupleHashEntry entry)
#define EXEC_FLAG_BACKWARD
static TupleTableSlot * ExecProject(ProjectionInfo *projInfo)
static void * TupleHashEntryGetAdditional(TupleHashTable hashtable, TupleHashEntry entry)
#define ResetExprContext(econtext)
static bool ExecQual(ExprState *state, ExprContext *econtext)
static bool ExecQualAndReset(ExprState *state, ExprContext *econtext)
static size_t TupleHashEntrySize(void)
static TupleTableSlot * ExecProcNode(PlanState *node)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
static void ExecEvalExprNoReturnSwitchContext(ExprState *state, ExprContext *econtext)
#define EXEC_FLAG_EXPLAIN_ONLY
#define MakeExpandedObjectReadOnly(d, isnull, typlen)
#define palloc_array(type, count)
#define palloc0_array(type, count)
#define palloc0_object(type)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
void(* ExprContextCallbackFunction)(Datum arg)
#define SizeForFunctionCallInfo(nargs)
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
#define AGG_CONTEXT_WINDOW
#define LOCAL_FCINFO(name, nargs)
#define AGG_CONTEXT_AGGREGATE
struct FunctionCallInfoBaseData * FunctionCallInfo
#define FunctionCallInvoke(fcinfo)
#define fmgr_info_set_expr(expr, finfo)
uint32 hash_bytes_uint32(uint32 k)
void heap_freetuple(HeapTuple htup)
MinimalTupleData * MinimalTuple
#define HeapTupleIsValid(tuple)
#define SizeofMinimalTupleHeader
static void * GETSTRUCT(const HeapTupleData *tuple)
void initHyperLogLog(hyperLogLogState *cState, uint8 bwidth)
double estimateHyperLogLog(hyperLogLogState *cState)
void addHyperLogLog(hyperLogLogState *cState, uint32 hash)
void freeHyperLogLog(hyperLogLogState *cState)
#define IsParallelWorker()
#define INJECTION_POINT(name, arg)
#define IS_INJECTION_POINT_ATTACHED(name)
#define INJECTION_POINT_CACHED(name, arg)
List * lappend(List *list, void *datum)
List * lcons_int(int datum, List *list)
List * list_delete_last(List *list)
void list_free(List *list)
void list_free_deep(List *list)
void LogicalTapeRewindForRead(LogicalTape *lt, size_t buffer_size)
size_t LogicalTapeRead(LogicalTape *lt, void *ptr, size_t size)
int64 LogicalTapeSetBlocks(LogicalTapeSet *lts)
void LogicalTapeClose(LogicalTape *lt)
void LogicalTapeSetClose(LogicalTapeSet *lts)
LogicalTapeSet * LogicalTapeSetCreate(bool preallocate, SharedFileSet *fileset, int worker)
void LogicalTapeWrite(LogicalTape *lt, const void *ptr, size_t size)
LogicalTape * LogicalTapeCreate(LogicalTapeSet *lts)
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
RegProcedure get_opcode(Oid opno)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
char * get_func_name(Oid funcid)
void MemoryContextReset(MemoryContext context)
void pfree(void *pointer)
Size MemoryContextMemAllocated(MemoryContext context, bool recurse)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_MAXSIZE
#define ALLOCSET_DEFAULT_MINSIZE
#define ALLOCSET_DEFAULT_SIZES
#define ALLOCSET_DEFAULT_INITSIZE
#define CHECK_FOR_INTERRUPTS()
static void hashagg_finish_initial_spills(AggState *aggstate)
static void hash_agg_check_limits(AggState *aggstate)
static void initialize_hash_entry(AggState *aggstate, TupleHashTable hashtable, TupleHashEntry entry)
static void find_hash_columns(AggState *aggstate)
static bool agg_refill_hash_table(AggState *aggstate)
void ExecAggEstimate(AggState *node, ParallelContext *pcxt)
static void hash_agg_enter_spill_mode(AggState *aggstate)
static Datum GetAggInitVal(Datum textInitVal, Oid transtype)
static void find_cols(AggState *aggstate, Bitmapset **aggregated, Bitmapset **unaggregated)
void AggRegisterCallback(FunctionCallInfo fcinfo, ExprContextCallbackFunction func, Datum arg)
static void build_hash_table(AggState *aggstate, int setno, double nbuckets)
#define HASHAGG_HLL_BIT_WIDTH
static void agg_fill_hash_table(AggState *aggstate)
Aggref * AggGetAggref(FunctionCallInfo fcinfo)
static void initialize_aggregate(AggState *aggstate, AggStatePerTrans pertrans, AggStatePerGroup pergroupstate)
static TupleTableSlot * fetch_input_tuple(AggState *aggstate)
static void hashagg_spill_finish(AggState *aggstate, HashAggSpill *spill, int setno)
static bool find_cols_walker(Node *node, FindColsContext *context)
void ExecAggInitializeWorker(AggState *node, ParallelWorkerContext *pwcxt)
void ExecAggRetrieveInstrumentation(AggState *node)
static TupleTableSlot * project_aggregates(AggState *aggstate)
static MinimalTuple hashagg_batch_read(HashAggBatch *batch, uint32 *hashp)
static double hash_choose_num_buckets(double hashentrysize, double ngroups, Size memory)
static void process_ordered_aggregate_multi(AggState *aggstate, AggStatePerTrans pertrans, AggStatePerGroup pergroupstate)
void ExecReScanAgg(AggState *node)
int AggCheckCallContext(FunctionCallInfo fcinfo, MemoryContext *aggcontext)
static void advance_transition_function(AggState *aggstate, AggStatePerTrans pertrans, AggStatePerGroup pergroupstate)
static void hash_agg_update_metrics(AggState *aggstate, bool from_tape, int npartitions)
static void finalize_aggregates(AggState *aggstate, AggStatePerAgg peraggs, AggStatePerGroup pergroup)
static void initialize_phase(AggState *aggstate, int newphase)
Size hash_agg_entry_size(int numTrans, Size tupleWidth, Size transitionSpace)
static void initialize_aggregates(AggState *aggstate, AggStatePerGroup *pergroups, int numReset)
static TupleTableSlot * agg_retrieve_hash_table_in_memory(AggState *aggstate)
void ExecAggInitializeDSM(AggState *node, ParallelContext *pcxt)
static void finalize_aggregate(AggState *aggstate, AggStatePerAgg peragg, AggStatePerGroup pergroupstate, Datum *resultVal, bool *resultIsNull)
#define HASHAGG_MAX_PARTITIONS
static void lookup_hash_entries(AggState *aggstate)
static TupleTableSlot * agg_retrieve_direct(AggState *aggstate)
static void hashagg_recompile_expressions(AggState *aggstate, bool minslot, bool nullcheck)
static void prepare_projection_slot(AggState *aggstate, TupleTableSlot *slot, int currentSet)
bool AggStateIsShared(FunctionCallInfo fcinfo)
static void build_pertrans_for_aggref(AggStatePerTrans pertrans, AggState *aggstate, EState *estate, Aggref *aggref, Oid transfn_oid, Oid aggtranstype, Oid aggserialfn, Oid aggdeserialfn, Datum initValue, bool initValueIsNull, Oid *inputTypes, int numArguments)
static TupleTableSlot * agg_retrieve_hash_table(AggState *aggstate)
static void process_ordered_aggregate_single(AggState *aggstate, AggStatePerTrans pertrans, AggStatePerGroup pergroupstate)
static void advance_aggregates(AggState *aggstate)
static TupleTableSlot * ExecAgg(PlanState *pstate)
static void prepare_hash_slot(AggStatePerHash perhash, TupleTableSlot *inputslot, TupleTableSlot *hashslot)
static void build_hash_tables(AggState *aggstate)
void ExecEndAgg(AggState *node)
#define HASHAGG_READ_BUFFER_SIZE
static void hashagg_reset_spill_state(AggState *aggstate)
static Size hashagg_spill_tuple(AggState *aggstate, HashAggSpill *spill, TupleTableSlot *inputslot, uint32 hash)
static void select_current_set(AggState *aggstate, int setno, bool is_hash)
static void finalize_partialaggregate(AggState *aggstate, AggStatePerAgg peragg, AggStatePerGroup pergroupstate, Datum *resultVal, bool *resultIsNull)
AggState * ExecInitAgg(Agg *node, EState *estate, int eflags)
static void hashagg_spill_init(HashAggSpill *spill, LogicalTapeSet *tapeset, int used_bits, double input_groups, double hashentrysize)
#define HASHAGG_MIN_PARTITIONS
void hash_agg_set_limits(double hashentrysize, double input_groups, int used_bits, Size *mem_limit, uint64 *ngroups_limit, int *num_partitions)
MemoryContext AggGetTempMemoryContext(FunctionCallInfo fcinfo)
#define HASHAGG_PARTITION_FACTOR
static HashAggBatch * hashagg_batch_new(LogicalTape *input_tape, int setno, int64 input_tuples, double input_card, int used_bits)
#define HASHAGG_WRITE_BUFFER_SIZE
static void hash_create_memory(AggState *aggstate)
static int hash_choose_num_partitions(double input_groups, double hashentrysize, int used_bits, int *log2_npartitions)
Oid exprCollation(const Node *expr)
#define expression_tree_walker(n, w, c)
size_t get_hash_memory_limit(void)
#define DO_AGGSPLIT_SKIPFINAL(as)
#define IsA(nodeptr, _type_)
#define DO_AGGSPLIT_DESERIALIZE(as)
#define DO_AGGSPLIT_COMBINE(as)
#define DO_AGGSPLIT_SERIALIZE(as)
#define castNode(_type_, nodeptr)
#define InvokeFunctionExecuteHook(objectId)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
void build_aggregate_finalfn_expr(Oid *agg_input_types, int num_finalfn_inputs, Oid agg_state_type, Oid agg_result_type, Oid agg_input_collation, Oid finalfn_oid, Expr **finalfnexpr)
void build_aggregate_deserialfn_expr(Oid deserialfn_oid, Expr **deserialfnexpr)
void build_aggregate_transfn_expr(Oid *agg_input_types, int agg_num_inputs, int agg_num_direct_inputs, bool agg_variadic, Oid agg_state_type, Oid agg_input_collation, Oid transfn_oid, Oid invtransfn_oid, Expr **transfnexpr, Expr **invtransfnexpr)
int get_aggregate_argtypes(Aggref *aggref, Oid *inputTypes)
void build_aggregate_serialfn_expr(Oid serialfn_oid, Expr **serialfnexpr)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
END_CATALOG_STRUCT typedef FormData_pg_aggregate * Form_pg_aggregate
FormData_pg_attribute * Form_pg_attribute
#define pg_nextpower2_size_t
static uint32 pg_ceil_log2_32(uint32 num)
#define pg_prevpower2_size_t
static int list_length(const List *l)
static void * list_nth(const List *list, int n)
#define list_nth_node(type, list, n)
END_CATALOG_STRUCT typedef FormData_pg_proc * Form_pg_proc
static bool DatumGetBool(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static unsigned hash(unsigned *uv, int n)
void * shm_toc_allocate(shm_toc *toc, Size nbytes)
void shm_toc_insert(shm_toc *toc, uint64 key, void *address)
void * shm_toc_lookup(shm_toc *toc, uint64 key, bool noError)
#define shm_toc_estimate_chunk(e, sz)
#define shm_toc_estimate_keys(e, cnt)
Size add_size(Size s1, Size s2)
Size mul_size(Size s1, Size s2)
TupleTableSlot * hashslot
TupleHashIterator hashiter
AttrNumber * hashGrpColIdxHash
AttrNumber * hashGrpColIdxInput
ExprState * evaltrans_cache[2][2]
TupleTableSlot * sortslot
Tuplesortstate ** sortstates
TupleTableSlot * uniqslot
FunctionCallInfo deserialfn_fcinfo
FunctionCallInfo serialfn_fcinfo
FunctionCallInfo transfn_fcinfo
MemoryContext hash_metacxt
Tuplesortstate * sort_out
MemoryContext hash_tuplescxt
AggStatePerTrans pertrans
ExprContext * hashcontext
SharedAggInfo * shared_info
AggStatePerGroup * pergroups
uint64 hash_ngroups_current
ExprContext ** aggcontexts
MemoryContext ecxt_per_tuple_memory
TupleTableSlot * ecxt_innertuple
TupleTableSlot * ecxt_outertuple
NullableDatum args[FLEXIBLE_ARRAY_MEMBER]
hyperLogLogState * hll_card
LogicalTape ** partitions
shm_toc_estimator estimator
Instrumentation * instrument
ExprContext * ps_ExprContext
TupleTableSlot * ss_ScanTupleSlot
AggregateInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]
TupleDesc tts_tupleDescriptor
const TupleTableSlotOps *const tts_ops
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Datum SysCacheGetAttr(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
TargetEntry * get_sortgroupclause_tle(SortGroupClause *sgClause, List *targetList)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
void tuplesort_performsort(Tuplesortstate *state)
void tuplesort_end(Tuplesortstate *state)
void tuplesort_puttupleslot(Tuplesortstate *state, TupleTableSlot *slot)
Tuplesortstate * tuplesort_begin_heap(TupleDesc tupDesc, int nkeys, AttrNumber *attNums, Oid *sortOperators, Oid *sortCollations, bool *nullsFirstFlags, int workMem, SortCoordinate coordinate, int sortopt)
bool tuplesort_gettupleslot(Tuplesortstate *state, bool forward, bool copy, TupleTableSlot *slot, Datum *abbrev)
Tuplesortstate * tuplesort_begin_datum(Oid datumType, Oid sortOperator, Oid sortCollation, bool nullsFirstFlag, int workMem, SortCoordinate coordinate, int sortopt)
bool tuplesort_getdatum(Tuplesortstate *state, bool forward, bool copy, Datum *val, bool *isNull, Datum *abbrev)
static void slot_getsomeattrs(TupleTableSlot *slot, int attnum)
static HeapTuple ExecCopySlotHeapTuple(TupleTableSlot *slot)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
static void slot_getallattrs(TupleTableSlot *slot)