 once per row.
* After all rows have finished processing, x_deinit() is called, if present,
to clean up by de-allocating any memory that was allocated in x_init().

* MariaDB will first call the C/C++ initialization function, x_init(),
assuming it exists. All setup will be performed, and if it returns an error,
the SQL statement is aborted and no further functions are called.
* The table is sorted according to the GROUP BY expression.
* x_clear() is called for the first row of each new group.
* x_add() is called once per row for each row in the same group.
* x() is called when the group changes, or after the last row, to get the
aggregate result. 
* The latter three steps are repeated until all rows have been processed.
* After all rows have finished processing, x_deinit() is called, if present,
to clean up by de-allocating any memory that was allocated in x_init().

Examples
--------

For an example, see sql/udf_example.cc in the source tree. For a collection of
existing UDFs see https://github.com/mysqludf.

URL: https://mariadb.com/kb/en/creating-user-defined-functions/https://mariadb.com/kb/en/creating-user-defined-functions/