Oracle 5.0 Reference Manual page 2833

Table of Contents

Advertisement

my_bool const_item
xxx_init()
otherwise.
21.2.2.2. UDF Calling Sequences for Aggregate Functions
This section describes the different functions that you need to define when you create an aggregate
UDF.
Section 21.2.2, "Adding a New User-Defined
these functions.
xxx_reset()
This function is called when MySQL finds the first row in a new group. It should reset any internal
summary variables and then use the given
summary value for the group. Declare
void xxx_reset(UDF_INIT *initid, UDF_ARGS *args,
xxx_reset()
instead. However, you can define both
UDF work with older versions of the server. (If you do include both functions, the
function in many cases can be implemented internally by calling
and then calling
xxx_clear()
This function is called when MySQL needs to reset the summary results. It is called at the beginning
for each new group but can also be called to reset the values for a query where there were no
matching rows. Declare
void xxx_clear(UDF_INIT *initid, char *is_null, char *error);
is_null
If something went wrong, you can store a value in the variable to which the
points to a single-byte variable, not to a string buffer.
error
xxx_clear()
xxx_add()
This function is called for all rows that belong to the same group. You should use it to add the value
in the
UDF_ARGS
void xxx_add(UDF_INIT *initid, UDF_ARGS *args,
The
function for an aggregate UDF should be declared the same way as for a nonaggregate
xxx()
UDF. See
Section 21.2.2.1, "UDF Calling Sequences for Simple
For an aggregate UDF, MySQL calls the
processed. You should normally never access its
based on your internal summary variables.
Return value handling in
Section 21.2.2.4, "UDF Return Values and Error
The
xxx_reset()
functions for nonaggregate UDFs. See
The pointer arguments to
xxx_clear(),
Adding a New User-Defined Function
should set
const_item
char *is_null, char *error);
is not needed or used in MySQL 5.0, in which the UDF interface uses
to add the
xxx_add()
xxx_clear()
is set to point to
CHAR(0)
is required by MySQL 5.0.
argument to your internal summary variable.
char *is_null, char *error);
should be done the same way as for a nonaggregate UDF. See
xxx()
and
xxx_add()
is_null
and xxx(). You can use this to remember that you got an error or
xxx_add()
to
if
always returns the same value and to
1
xxx()
Function", describes the order in which MySQL calls
argument as the first value in your internal
UDF_ARGS
as follows:
xxx_reset()
and
xxx_reset()
argument as the first value in the group.)
UDF_ARGS
as follows:
before calling xxx_clear().
function after all rows in the group have been
xxx()
UDF_ARGS
Handling".
functions handle their
Section 21.2.2.3, "UDF Argument
and
are the same for all calls to xxx_reset(),
error
2813
if you want to have your
xxx_clear()
to reset all variables,
xxx_clear()
error
Functions".
argument here but instead return a value
argument the same way as
UDF_ARGS
Processing".
0
xxx_clear()
xxx_reset()
argument points.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents