Oracle 5.0 Reference Manual page 2836

Table of Contents

Advertisement

In this case, the
args->attributes[0] = "expr1"
args->attribute_lengths[0] = 5
args->attributes[1] = "alias1"
args->attribute_lengths[1] = 6
args->attributes[2] = "alias2"
args->attribute_lengths[2] = 6
unsigned long *attribute_lengths
The
attribute_lengths
21.2.2.4. UDF Return Values and Error Handling
The initialization function should return
xxx_init()
is returned to the client. The message buffer is
try to keep the message to less than 80 characters so that it fits the width of a standard terminal
screen.
The return value of the main function
functions. A string function should return a pointer to the result and set
of the return value. For example:
memcpy(result, "result string", 13);
*length = 13;
MySQL passes a buffer to the
long to hold 255 characters, which can be multi-byte characters. The
result in this buffer if it fits, in which case the return value should be a pointer to the buffer. If the
function stores the result in a different buffer, it should return a pointer to that buffer.
If your string function does not use the supplied buffer (for example, if it needs to return a string
longer than 255 characters), you must allocate the space for your own buffer with
xxx_init()
store the allocated memory in the
See
Section 21.2.2.1, "UDF Calling Sequences for Simple
To indicate a return value of
*is_null = 1;
To indicate an error return in the main function, set
*error = 1;
If
sets
xxx()
subsequent rows processed by the statement in which
for subsequent rows.)
21.2.2.5. Compiling and Installing User-Defined Functions
Files implementing UDFs must be compiled and installed on the host where the server runs. This
process is described below for the example UDF file
MySQL source distribution.
If a UDF will be referred to in statements that will be replicated to slave servers, you must ensure that
every slave also has the function available. Otherwise, replication will fail on the slaves when they
attempt to invoke the function.
Adding a New User-Defined Function
and
attributes
array indicates the length of each argument name.
should store a null-terminated error message in the
xxx()
function or your
xxx()
ptr
in the main function, set
NULL
to
for any row, the function value is
*error
1
attribute_lengths
if no error occurred and
0
MYSQL_ERRMSG_SIZE
is the function value, for
xxx()
function using the
result
function and free it in your
slot in the
UDF_INIT
Functions".
*is_null
*error
XXX()
sql/udf_example.c
2816
arrays will have these values:
otherwise. If an error occurs,
1
parameter. The message
message
characters long, but you should
and
long long
to the length (in bytes)
*length
parameter. This buffer is sufficiently
function can store the
xxx()
malloc()
function. You can
xxx_deinit()
structure for reuse by future
to 1:
to 1:
for the current row and for any
NULL
was invoked.
(xxx()
that is included in the
double
in your
calls.
xxx()
is not even called

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents