Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-37740

LOCATE(X,Y,NULL) is not NULL

    XMLWordPrintable

Details

    • Unexpected results

    Description

      Hi,

      Based on the document https://mariadb.com/docs/server/reference/sql-functions/string-functions/locate, if any argument of LOCATE is NULL, LOCATE returns NULL.

      However, it returns 0 in the following test case:

      CREATE TABLE t0(c0 REAL);
      CREATE TABLE IF NOT EXISTS t1 LIKE t0;
      INSERT INTO t0 VALUES (-1);
      SELECT t1.c0, LOCATE(t0.c0, t0.c0, t1.c0) FROM t0 LEFT JOIN t1 ON false;
      

      c0      LOCATE(t0.c0, t0.c0, t1.c0)
      NULL    0
      

      I tried this in MySQL and found it returns NULL.

      Attachments

        Activity

          People

            serg Sergei Golubchik
            ChiZhang Chi Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.