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

CASE function handles NULL inconsistently

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.5.9, 10.3(EOL), 10.4(EOL), 10.5(EOL)
    • 10.11.14, 11.4.8, 11.8.3
    • Server
    • None
    • Linux
    • Unexpected results

    Description

      A literal NULL behaves differently from a computed NULL:

      MariaDB [anr]> select case 'X' when null then 1 when 'X' then 2 else 3 end;
      +------------------------------------------------------+
      | case 'X' when null then 1 when 'X' then 2 else 3 end |
      +------------------------------------------------------+
      |                                                    2 |
      +------------------------------------------------------+
      1 row in set (0.000 sec)
       
      MariaDB [anr]> select case 'X' when 1/0 then 1 when 'X' then 2 else 3 end;
      +-----------------------------------------------------+
      | case 'X' when 1/0 then 1 when 'X' then 2 else 3 end |
      +-----------------------------------------------------+
      |                                                   3 |
      +-----------------------------------------------------+
      1 row in set, 1 warning (0.000 sec)
      

      The second select should (imho) also evaluate to 2. Versions of MySQL I've check (5.6/5.7) give consistent results (return the value 2 in all cases).

      Attachments

        Activity

          People

            serg Sergei Golubchik
            raymond Raymond Michiels
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.