[MDEV-25415] CASE function handles NULL inconsistently Created: 2021-04-14  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.5.9, 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Raymond Michiels Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 0
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).



 Comments   
Comment by Alice Sherepa [ 2021-04-16 ]

Thanks for the report! Reproducible on 10.3-10.5, not on 5.5-10.2

Generated at Thu Feb 08 09:37:31 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.