Skip to content

SQL: fix string functions handling of NULL parameter values #58907

@bpintea

Description

@bpintea

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions