27#include "utils/fmgrprotos.h"
127 elog(
ERROR,
"ordered-set aggregate called in non-aggregate context");
144 elog(
ERROR,
"ordered-set aggregate called in non-aggregate context");
146 elog(
ERROR,
"ordered-set aggregate support function called for non-ordered-set aggregate");
226 for (
i = 1;
i <= natts;
i++)
251 elog(
ERROR,
"ordered-set aggregate support function does not support multiple aggregated columns");
400 for (
i = 0;
i < nargs;
i++)
446 errmsg(
"percentile value %g is not between 0 and 1",
480 elog(
ERROR,
"missing row in percentile_disc");
485 elog(
ERROR,
"missing row in percentile_disc");
533 int64 second_row = 0;
551 errmsg(
"percentile value %g is not between 0 and 1",
581 elog(
ERROR,
"missing row in percentile_cont");
585 elog(
ERROR,
"missing row in percentile_cont");
589 if (first_row == second_row)
597 elog(
ERROR,
"missing row in percentile_cont");
651 if (
a->first_row !=
b->first_row)
652 return (
a->first_row <
b->first_row) ? -1 : 1;
653 if (
a->second_row !=
b->second_row)
654 return (
a->second_row <
b->second_row) ? -1 : 1;
691 errmsg(
"percentile value %g is not between 0 and 1",
819 elog(
ERROR,
"missing row in percentile_disc");
823 elog(
ERROR,
"missing row in percentile_disc");
850 int16 typLen,
bool typByVal,
char typAlign,
948 elog(
ERROR,
"missing row in percentile_cont");
952 elog(
ERROR,
"missing row in percentile_cont");
973 elog(
ERROR,
"missing row in percentile_cont");
1061 equalfn = &(
osastate->qstate->equalfn);
1149 (nargs + 1) != tupdesc->
natts ||
1151 elog(
ERROR,
"type mismatch in hypothetical-set function");
1154 for (
i = 0;
i < nargs;
i++)
1159 elog(
ERROR,
"type mismatch in hypothetical-set function");
1172 int64 *number_of_rows)
1185 *number_of_rows = 0;
1190 *number_of_rows =
osastate->number_of_rows;
1194 elog(
ERROR,
"wrong number of arguments in hypothetical-set function");
1205 for (
i = 0;
i < nargs;
i++)
1303 int numDistinctCols;
1318 econtext =
osastate->qstate->econtext;
1326 econtext =
osastate->qstate->econtext;
1332 elog(
ERROR,
"wrong number of arguments in hypothetical-set function");
1341 numDistinctCols =
osastate->qstate->numSortCols - 1;
1344 compareTuple =
osastate->qstate->compareTuple;
1345 if (compareTuple ==
NULL)
1358 osastate->qstate->compareTuple = compareTuple;
1367 for (
i = 0;
i < nargs;
i++)
Datum idx(PG_FUNCTION_ARGS)
#define PG_GETARG_ARRAYTYPE_P(n)
ArrayType * construct_empty_array(Oid elmtype)
ArrayType * construct_md_array(Datum *elems, bool *nulls, int ndims, int *dims, int *lbs, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
Datum interval_mi(PG_FUNCTION_ARGS)
Datum interval_pl(PG_FUNCTION_ARGS)
Datum interval_mul(PG_FUNCTION_ARGS)
#define Assert(condition)
#define OidIsValid(objectId)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
ExprState * execTuplesMatchPrepare(TupleDesc desc, int numCols, const AttrNumber *keyColIdx, const Oid *eqOperators, const Oid *collations, PlanState *parent)
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
const TupleTableSlotOps TTSOpsMinimalTuple
TupleDesc ExecTypeFromTL(List *targetList)
ExprContext * CreateStandaloneExprContext(void)
static bool ExecQualAndReset(ExprState *state, ExprContext *econtext)
#define palloc_object(type)
#define palloc0_object(type)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_FLOAT8(n)
#define PG_RETURN_FLOAT8(x)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_INT64(x)
#define PG_GETARG_DATUM(n)
#define AGG_CONTEXT_AGGREGATE
#define PG_RETURN_DATUM(x)
#define PG_RETURN_POINTER(x)
#define PG_GET_COLLATION()
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
RegProcedure get_opcode(Oid opno)
void pfree(void *pointer)
#define CHECK_FOR_INTERRUPTS()
void AggRegisterCallback(FunctionCallInfo fcinfo, ExprContextCallbackFunction func, Datum arg)
Aggref * AggGetAggref(FunctionCallInfo fcinfo)
int AggCheckCallContext(FunctionCallInfo fcinfo, MemoryContext *aggcontext)
bool AggStateIsShared(FunctionCallInfo fcinfo)
Oid exprType(const Node *expr)
Oid exprCollation(const Node *expr)
Datum percentile_cont_float8_final(PG_FUNCTION_ARGS)
static OSAPerGroupState * ordered_set_startup(FunctionCallInfo fcinfo, bool use_tuples)
Datum hypothetical_percent_rank_final(PG_FUNCTION_ARGS)
Datum percentile_disc_final(PG_FUNCTION_ARGS)
Datum hypothetical_rank_final(PG_FUNCTION_ARGS)
static Datum percentile_cont_multi_final_common(FunctionCallInfo fcinfo, Oid expect_type, int16 typLen, bool typByVal, char typAlign, LerpFunc lerpfunc)
static Datum float8_lerp(Datum lo, Datum hi, double pct)
Datum hypothetical_cume_dist_final(PG_FUNCTION_ARGS)
static struct pct_info * setup_pct_info(int num_percentiles, const Datum *percentiles_datum, const bool *percentiles_null, int64 rowcount, bool continuous)
static int64 hypothetical_rank_common(FunctionCallInfo fcinfo, int flag, int64 *number_of_rows)
static Datum interval_lerp(Datum lo, Datum hi, double pct)
Datum ordered_set_transition(PG_FUNCTION_ARGS)
Datum ordered_set_transition_multi(PG_FUNCTION_ARGS)
Datum percentile_disc_multi_final(PG_FUNCTION_ARGS)
Datum hypothetical_dense_rank_final(PG_FUNCTION_ARGS)
static void ordered_set_shutdown(Datum arg)
static Datum percentile_cont_final_common(FunctionCallInfo fcinfo, Oid expect_type, LerpFunc lerpfunc)
Datum percentile_cont_float8_multi_final(PG_FUNCTION_ARGS)
Datum(* LerpFunc)(Datum lo, Datum hi, double pct)
Datum mode_final(PG_FUNCTION_ARGS)
Datum percentile_cont_interval_final(PG_FUNCTION_ARGS)
Datum percentile_cont_interval_multi_final(PG_FUNCTION_ARGS)
static void hypothetical_check_argtypes(FunctionCallInfo fcinfo, int nargs, TupleDesc tupdesc)
static int pct_info_cmp(const void *pa, const void *pb)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
FormData_pg_attribute * Form_pg_attribute
static int list_length(const List *l)
#define qsort(a, b, c, d)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
#define Float8GetDatumFast(X)
static float8 DatumGetFloat8(Datum X)
static Pointer DatumGetPointer(Datum X)
static Datum Float8GetDatum(float8 X)
static Datum Int32GetDatum(int32 X)
static int32 DatumGetInt32(Datum X)
TupleTableSlot * ecxt_innertuple
TupleTableSlot * ecxt_outertuple
OSAPerQueryState * qstate
Tuplesortstate * sortstate
TupleDesc tts_tupleDescriptor
TargetEntry * get_sortgroupclause_tle(SortGroupClause *sgClause, List *targetList)
void FreeTupleDesc(TupleDesc tupdesc)
TupleDesc CreateTemplateTupleDesc(int natts)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
void TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno, TupleDesc src, AttrNumber srcAttno)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
void tuplesort_rescan(Tuplesortstate *state)
void tuplesort_performsort(Tuplesortstate *state)
bool tuplesort_skiptuples(Tuplesortstate *state, int64 ntuples, bool forward)
void tuplesort_end(Tuplesortstate *state)
#define TUPLESORT_RANDOMACCESS
void tuplesort_putdatum(Tuplesortstate *state, Datum val, bool isNull)
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 Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)