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

CASE function handles NULL inconsistently

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Confirmed (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.3, 10.4, 10.5, 10.5.9
    • Fix Version/s: 10.3, 10.4, 10.5
    • Component/s: None
    • Labels:
      None
    • Environment:
      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

            Assignee:
            serg Sergei Golubchik
            Reporter:
            raymond Raymond Michiels
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: