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

CASE function handles NULL inconsistently

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5.9, 10.3, 10.4, 10.5
    • 10.4, 10.5
    • None
    • None
    • Linux

    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:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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