Some string functions that take an integer parameter - like SUBSTRING or INSERT - exhibit a potentially unexpected behavior when any of the integer parameters is computed from a column containing NULL values: the function simply returns the original string [expression] value, applying no operation.
Example: SELECT SUBSTRING(str_column, int_column_with_nulls, some_lenght) = str_column will return true everyWHERE int_column_with_nulls IS NULL.
This is different from directly providing a NULL literal for any of the parameters, when the function returns NULL (as expected).
Note that other RDBMSes (ex: SQL Server, Postgres, MariaDB) return NULL when any parameter - either literal or attribute - is NULL; we should arguably follow lead or at least document the behavior.
Some string functions that take an integer parameter - like SUBSTRING or INSERT - exhibit a potentially unexpected behavior when any of the integer parameters is computed from a column containing
NULLvalues: the function simply returns the original string [expression] value, applying no operation.Example:
SELECT SUBSTRING(str_column, int_column_with_nulls, some_lenght) = str_columnwill returntrueeveryWHERE int_column_with_nulls IS NULL.This is different from directly providing a
NULLliteral for any of the parameters, when the function returnsNULL(as expected).Note that other RDBMSes (ex: SQL Server, Postgres, MariaDB) return
NULLwhen any parameter - either literal or attribute - isNULL; we should arguably follow lead or at least document the behavior.