-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
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.