Oid combineType;
/*
- * Combine function must have 2 argument, each of which is the trans
- * type
+ * Combine function must have 2 arguments, each of which is the trans
+ * type. VARIADIC doesn't affect it.
*/
fnArgs[0] = aggTransType;
fnArgs[1] = aggTransType;
- combinefn = lookup_agg_function(aggcombinefnName, 2, fnArgs,
- variadicArgType, &combineType);
+ combinefn = lookup_agg_function(aggcombinefnName, 2,
+ fnArgs, InvalidOid,
+ &combineType);
- /* Ensure the return type matches the aggregates trans type */
+ /* Ensure the return type matches the aggregate's trans type */
if (combineType != aggTransType)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
/*
* A combine function to combine INTERNAL states must accept nulls and
- * ensure that the returned state is in the correct memory context.
+ * ensure that the returned state is in the correct memory context. We
+ * cannot directly check the latter, but we can check the former.
*/
if (aggTransType == INTERNALOID && func_strict(combinefn))
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("combine function with transition type %s must not be declared STRICT",
format_type_be(aggTransType))));
-
}
/*
*/
if (aggserialfnName)
{
+ /* signature is always serialize(internal) returns bytea */
fnArgs[0] = INTERNALOID;
serialfn = lookup_agg_function(aggserialfnName, 1,
- fnArgs, variadicArgType,
+ fnArgs, InvalidOid,
&rettype);
if (rettype != BYTEAOID)
*/
if (aggdeserialfnName)
{
+ /* signature is always deserialize(bytea, internal) returns internal */
fnArgs[0] = BYTEAOID;
fnArgs[1] = INTERNALOID; /* dummy argument for type safety */
deserialfn = lookup_agg_function(aggdeserialfnName, 2,
- fnArgs, variadicArgType,
+ fnArgs, InvalidOid,
&rettype);
if (rettype != INTERNALOID)
/*
* lookup_agg_function
- * common code for finding transfn, invtransfn, finalfn, and combinefn
+ * common code for finding aggregate support functions
+ *
+ * fnName: possibly-schema-qualified function name
+ * nargs, input_types: expected function argument types
+ * variadicArgType: type of variadic argument if any, else InvalidOid
*
* Returns OID of function, and stores its return type into *rettype
*