* AggCheckCallContext - test if a SQL function is being called as an aggregate * * The transition and/or final functions of an aggregate may want to verify * that they are being called as aggregates, rather than as plain SQL * functions. They should use this function to do so. The return value * is nonzero if being called as an aggregate, or zero if not. (Specific * nonzero values are AGG
| 4892 | * cache it in the transvalue itself (for internal-type transvalues). |
| 4893 | */ |
| 4894 | int |
| 4895 | AggCheckCallContext(FunctionCallInfo fcinfo, MemoryContext *aggcontext) |
| 4896 | { |
| 4897 | if (fcinfo->context && IsA(fcinfo->context, AggState)) |
| 4898 | { |
| 4899 | if (aggcontext) |
| 4900 | { |
| 4901 | AggState *aggstate = ((AggState *) fcinfo->context); |
| 4902 | ExprContext *cxt = aggstate->curaggcontext; |
| 4903 | |
| 4904 | *aggcontext = cxt->ecxt_per_tuple_memory; |
| 4905 | } |
| 4906 | return AGG_CONTEXT_AGGREGATE; |
| 4907 | } |
| 4908 | if (fcinfo->context && IsA(fcinfo->context, WindowAggState)) |
| 4909 | { |
| 4910 | if (aggcontext) |
| 4911 | *aggcontext = ((WindowAggState *) fcinfo->context)->curaggcontext; |
| 4912 | return AGG_CONTEXT_WINDOW; |
| 4913 | } |
| 4914 | |
| 4915 | /* this is just to prevent "uninitialized variable" warnings */ |
| 4916 | if (aggcontext) |
| 4917 | *aggcontext = NULL; |
| 4918 | return 0; |
| 4919 | } |
| 4920 | |
| 4921 | /* |
| 4922 | * AggGetAggref - allow an aggregate support function to get its Aggref |
no outgoing calls
no test coverage detected