Modifiers in a C UDR

The following table shows the routine modifiers that are valid for C routines.
Routine modifier Description Valid for external function Valid for external procedure
CLASS Specifies a virtual-processor class in which to run the UDR Yes Yes
COSTFUNC Specifies the name of the cost function for this UDR Yes Yes
HANDLESNULLS Specifies that the UDR can handle null arguments Yes Yes
INTERNAL Specifies that the UDR is an internal routine; that is, that the routine is not available for use in an SQL or SPL statement Yes Yes
ITERATOR Specifies that the UDR is an iterator function Yes No
NEGATOR Specifies that the UDR is a negator function Yes No
NOT VARIANT Specifies that all invocations of the UDR with the same arguments return the same value Yes No
PARALLELIZABLE Routine can be executed in parallel Yes Yes
PERCALL_COST Specifies the cost of execution for the UDR Yes Yes
SELCONST Specifies the selectivity of the UDR Yes No
SELFUNC Specifies the name of the selectivity function for this UDR Yes No
STACK Specifies the stack size for the UDR Yes Yes
VARIANT Specifies that all invocations of the UDR with the same arguments do not necessarily return the same value Yes No
The following example shows how to use the WITH clause to specify a set of modifiers when you create an external-language function:
CREATE FUNCTION lessthan (arg1 basetype2, arg2 basetype2)
RETURNING BOOLEAN
WITH (HANDLESNULLS, NOT VARIANT)
EXTERNAL NAME '/usr/lib/basetype2/lib/libbtype2.so(basetype2_lessthan)'
LANGUAGE C

In this example, the HANDLESNULLS modifier indicates that the basetype2_lessthan() function (in the shared library /usr/lib/basetype2/lib/libbtype2.so) is coded to recognize SQL null. If HANDLESNULL is not set, the routine manager does not execute the UDR if any arguments of the routine are null; it simply returns null.