The scalar UDF descriptor structure, a_v3_extfn_scalar, is defined as:
typedef struct a_v3_extfn_scalar { // // Metadata descriptor for a scalar UDF // supplied by the UDF library to the server // An optional pointer to an initialize function void (*_start_extfn)(a_v3_extfn_scalar_context * cntxt); // // An optional pointer to a shutdown function void (*_finish_extfn)(a_v3_extfn_scalar_context * cntxt); // // A required pointer to a function that will be // called for each invocation of the UDF on a // new set of argument values void (*_evaluate_extfn)(a_v3_extfn_scalar_context * cntxt, void *args_handle); // RESERVED FIELDS MUST BE INITIALIZED TO NULL void *reserved1_must_be_null; void *reserved2_must_be_null; void *reserved3_must_be_null; void *reserved4_must_be_null; void *reserved5_must_be_null; … } a_v3_extfn_scalar;
There should always be a single instance of a_v3_extfn_scalar for each defined scalar UDF. If the optional initialization function is not supplied, the corresponding value in the descriptor structure should be the null pointer. Similarly, if the shutdown function is not supplied, the corresponding value in the descriptor structure should be the null pointer.
The initialization function is called at least once before any calls to the evaluation routine, and the shutdown function is called at least once after the last evaluation call. The initialization and shutdown functions are normally called only once per usage.