Extending a built-in aggregate
To extend a built-in aggregate function with a C user-defined function:
Suppose you want to use the SUM aggregate on complex numbers,
which are stored in the following user-defined data type: a named
row type named complexnum_t. The following code fragment shows
the CREATE ROW TYPE statement that registers the complexnum_t named
row type.
Figure 1. A
named row type to hold a complex number
CREATE ROW TYPE complexnum_t
(real_part SMALLFLOAT,
imaginary_part SMALLFLOAT);
The following sections show how to extend the SUM aggregate on the complexnum_t named row type.