Comments - Stored Aggregate Functions
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.
In attempting to short circuit some custom aggregate functions I discovered that custom aggregate functions must loop through entire cursor set to avoid erroneous results.
Here are 2 examples of trivial aggregate functions that return the "first" item in the aggregate cursor.
The first one (aggFirst_int) returns results as expected, storing the first item in the list, then looping through the cursor until the NOT FOUND HANDLER returns the result.
The second example does the same, but does not loop through the cursor until the NOT FOUND HANDLER is triggered, and returns the result immediately.
This produced the following results:
The built in aggregate functions all return the expected results, as does aggFirst_int(), but aggFirst_int2() returns results that were clearly processed from other rows.