Informix Error -9412: Return type of the support function <function-name> does not match the aggregate state type.
Cause and resolution
Return type of the support function <function-name> does not match the aggregate state type.
When you extend a built-in aggregate for a user-defined data type, the return type of the operator function must be the same as the data type for which you are extending the aggregate. For example, if you try to use the SUM aggregate on the "new_type" data type, thedatabase server looks for a plus() function with the following signature:
CREATE FUNCTION plus(c1 new_type, c2 new_type) RETURNING new_type;
This error can also occur for user-defined aggregates if the return type of an INIT support function is not the same as that of the ITER or COMBINE function. For user-defined types, make sure that the return types of the INIT function (if any), ITER function, and COMBINE function are the same as the user-defined type.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-9412 fires when a support function's return type doesn't match the type it's extending an aggregate for — per the official guidance.
- An operator function (e.g.
plus()for SUM) returning a type other than the UDT it extends the aggregate for, per the official guidance — the first named cause. - An INIT function's return type differing from the ITER or COMBINE function's return type, for a user-defined aggregate, per the official guidance — the second named cause.
Solutions / Resolution
- Make the operator function's return type match the UDT being extended, per the
official guidance — for example,
CREATE FUNCTION plus(c1 new_type, c2 new_type) RETURNING new_type. - For user-defined aggregates, make sure the INIT (if any), ITER, and COMBINE functions' return types are all the same as the user-defined type, per the official guidance.
Examples
A mismatched operator function return type
CREATE FUNCTION plus(c1 new_type, c2 new_type) RETURNING int;
-- -9412: should return new_type, not int
Corrected
CREATE FUNCTION plus(c1 new_type, c2 new_type) RETURNING new_type;
Diagnostic Checks
- Check the return types of the aggregate's INIT/ITER/COMBINE support functions against each other and against the aggregate's state type, and correct any mismatch.
Related Errors / Related Topics
- -9406 — "Cannot resolve support function for user-defined aggregate
." A related aggregate-support-function error, on a missing function rather than a return-type mismatch.
A support function's return type didn't match the aggregate's state type — align the INIT/ITER/COMBINE return types with the user-defined type.