| 1 | /*------------------------------------------------------------------------- |
| 2 | * |
| 3 | * parse_agg.h |
| 4 | * handle aggregates and window functions in parser |
| 5 | * |
| 6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
| 7 | * Portions Copyright (c) 1994, Regents of the University of California |
| 8 | * |
| 9 | * src/include/parser/parse_agg.h |
| 10 | * |
| 11 | *------------------------------------------------------------------------- |
| 12 | */ |
| 13 | #ifndef PARSE_AGG_H |
| 14 | #define PARSE_AGG_H |
| 15 | |
| 16 | #include "parser/parse_node.h" |
| 17 | |
| 18 | extern void transformAggregateCall(ParseState *pstate, Aggref *agg, |
| 19 | List *args, List *aggorder, |
| 20 | bool agg_distinct); |
| 21 | |
| 22 | extern Node *transformGroupingFunc(ParseState *pstate, GroupingFunc *g); |
| 23 | |
| 24 | extern void transformWindowFuncCall(ParseState *pstate, WindowFunc *wfunc, |
| 25 | WindowDef *windef); |
| 26 | |
| 27 | extern void parseCheckAggregates(ParseState *pstate, Query *qry); |
| 28 | |
| 29 | extern List *expand_grouping_sets(List *groupingSets, int limit); |
| 30 | |
| 31 | extern int get_aggregate_argtypes(Aggref *aggref, Oid *inputTypes); |
| 32 | |
| 33 | extern Oid resolve_aggregate_transtype(Oid aggfuncid, |
| 34 | Oid aggtranstype, |
| 35 | Oid *inputTypes, |
| 36 | int numArguments); |
| 37 | |
| 38 | extern void build_aggregate_transfn_expr(Oid *agg_input_types, |
| 39 | int agg_num_inputs, |
| 40 | int agg_num_direct_inputs, |
| 41 | bool agg_variadic, |
| 42 | Oid agg_state_type, |
| 43 | Oid agg_input_collation, |
| 44 | Oid transfn_oid, |
| 45 | Oid invtransfn_oid, |
| 46 | Expr **transfnexpr, |
| 47 | Expr **invtransfnexpr); |
| 48 | |
| 49 | extern void build_aggregate_combinefn_expr(Oid agg_state_type, |
| 50 | Oid agg_input_collation, |
| 51 | Oid combinefn_oid, |
| 52 | Expr **combinefnexpr); |
| 53 | |
| 54 | extern void build_aggregate_serialfn_expr(Oid serialfn_oid, |
| 55 | Expr **serialfnexpr); |
| 56 | |
| 57 | extern void build_aggregate_deserialfn_expr(Oid deserialfn_oid, |
| 58 | Expr **deserialfnexpr); |
| 59 | |
| 60 | extern void build_aggregate_finalfn_expr(Oid *agg_input_types, |
| 61 | int num_finalfn_inputs, |
| 62 | Oid agg_state_type, |
| 63 | Oid agg_result_type, |
| 64 | Oid agg_input_collation, |
| 65 | Oid finalfn_oid, |
| 66 | Expr **finalfnexpr); |
| 67 | |
| 68 | #endif /* PARSE_AGG_H */ |
| 69 | |