Details
Description
When executing a query that contains IF(x, SUM(\y), z), the results sometimes get mangled because the operation returns
{0, NULL}for a single column in MariaDB.
For example:
MariaDB [db1]> SELECT 'marker1',
-> IF(1, SUM(1), 1) AS IF_SUM1,
-> 'marker2',
-> IF(1, SUM(2), 2) AS IF_SUM2,
-> 'marker3',
-> 'marker4'
-> FROM mysql.user t1
-> WHERE t1.max_questions = 1;
+---------+---------+---------+---------+---------+---------+
| marker1 | IF_SUM1 | marker2 | IF_SUM2 | marker3 | marker4 |
+---------+---------+---------+---------+---------+---------+
| marker1 | 0 | NULL | marker2 | 0 | NULL |
+---------+---------+---------+---------+---------+---------+
1 row in set (0.00 sec)
The same query works normally on MySQL 5.5:
mysql> SELECT 'marker1',
-> IF(1, SUM(1), 1) AS IF_SUM1,
-> 'marker2',
-> IF(1, SUM(2), 2) AS IF_SUM2,
-> 'marker3',
-> 'marker4'
-> FROM mysql.user t1
-> WHERE t1.max_questions = 1;
+---------+---------+---------+---------+---------+---------+
| marker1 | IF_SUM1 | marker2 | IF_SUM2 | marker3 | marker4 |
+---------+---------+---------+---------+---------+---------+
| marker1 | NULL | marker2 | NULL | marker3 | marker4 |
+---------+---------+---------+---------+---------+---------+
1 row in set (0.00 sec)
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Geoff Montee, can you submit the dump of the dataset that you were using? Also, the testcase uses mysql.user. Is it essential that a system table is used or the issue can be repeated with non-system table as well?