UDSF return-value sizer methods
As described in Any-size return values for UDSFs, a UDSF that uses a generic return value must include a calculateSize() routine. (A UDAF cannot use a generic return value).
The calculateSize() method determines the upper limit of the return value size. It is called to allocate the memory for the result, but the length of the return value still must be set. A UDX can use the methods described in this section to calculate the size of and set a generic return value: