For now there is no special support for returning values
although it may be added at a later version.
To return an int or real result you just use a plain
C return statement with the appropriate return value.
To return a NULL value from any function you have to
set the variable pointed to by the is_null function
parameter to 1.
For strings up to 255 characters long you have to copy
the string to the location pointed to by the result
paramter and store its length in the varibale pointed
to by the length parameter. Returning longer strings
requires memory allocation within the UDF and is not yet
supported.
datetime values need to be returned as strings for now.
// returning an INT
return 42;
// returning a REAL
return 3.14;
// returning a NULL value for INT or REAL
*is_null = 1;
return 0;
// returing a STRING (up to 255 characters)
strcpy(result, string);
*length = strlen(string);
return;
// returning a binary safe STRING
memcpy(result, string, str_len);
*length = str_len;
return;
// returning a NULL STRING
*is_null = 1;
return;
// returing a DATETIME
strcpy(result, "2000-01-01 00:00:00");
*length = strlen(result);
return;