Being prepared for undesired conversions
The unsolicited NULL
<=> non-NULL
conversions described earlier usually only happen with legacy UDFs, but there are a lot of them around (most notably in ib_udf
).Also, nothing will stop a careless implementor from doing the same in a descriptor-style function.So the bottom line is: if you use a UDF and you don’t know how it behaves with respect to NULL
:
-
Look at its declaration to see how values are passed and returned.If it says “by descriptor”, it should be safe (though it never hurts to make sure).Ditto if arguments are followed by a
NULL
keyword.In all other cases, walk through the rest of the steps. -
If you have the source and you understand the language it’s written in, inspect the function code.
-
Test the function both with
NULL
input and with input like0
(for numerical arguments) and/or''
(for string arguments). -
If the function performs an undesired
NULL
<=> non-NULL
conversion, you’ll have to anticipate it in your code before calling the UDF (see also [nullguide-test-if-matters], elsewhere in this guide).
The declarations for the shipped UDF libraries can be found in the Firebird subdirectory examples
(v.1.0) or UDF
(v.1.5 and up).Look at the files with extension .sql