You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CASE WHEN NULL THEN 0 ELSE 1 END
returns different result from equivalent:
CASE WHEN IS NULL THEN 0 ELSE 1 END
Reproducible: Always
Steps to Reproduce:
start mserver5 (MonetDB 5 server v11.23.14)
start mclient
execute SQLs:
CREATE TABLE table_two (this_column INTEGER);
INSERT INTO table_two VALUES (1);
INSERT INTO table_two VALUES (2);
INSERT INTO table_two VALUES (null);
SELECT * FROM table_two;
SELECT this_column, (CASE WHEN this_column IS NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
-- correct output
SELECT this_column, (CASE this_column WHEN NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
-- incorrect output for the NULL case
DROP TABLE table_two;
Actual Results:
Welcome to mclient, the MonetDB/SQL interactive terminal (unreleased)
Database: MonetDB v11.23.14 (unreleased), 'demo'
Type \q to quit, ? for a list of available commands
auto commit mode: on
sql>CREATE TABLE table_two (this_column INTEGER);
operation successful (30.384ms)
sql>INSERT INTO table_two VALUES (1);
1 affected row (7.501ms)
sql>INSERT INTO table_two VALUES (2);
1 affected row (8.050ms)
sql>INSERT INTO table_two VALUES (null);
1 affected row (8.038ms)
sql>SELECT * FROM table_two;
+-------------+
| this_column |
+=============+
| 1 |
| 2 |
| null |
+-------------+
3 tuples (0.475ms)
sql>SELECT this_column, (CASE WHEN this_column IS NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
+-------------+------------+
| this_column | new_column |
+=============+============+
| 1 | 1 |
| 2 | 1 |
| null | 0 |
+-------------+------------+
3 tuples (0.680ms)
sql>-- correct output
sql>SELECT this_column, (CASE this_column WHEN NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
+-------------+------------+
| this_column | new_column |
+=============+============+
| 1 | 1 |
| 2 | 1 |
| null | 1 |
+-------------+------------+
3 tuples (1.140ms)
sql>-- incorrect output for the NULL case
sql>DROP TABLE table_two;
operation successful (11.339ms)
Expected Results:
sql>SELECT this_column, (CASE WHEN this_column IS NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
+-------------+------------+
| this_column | new_column |
+=============+============+
| 1 | 1 |
| 2 | 1 |
| null | 0 |
+-------------+------------+
3 tuples (0.680ms)
fixes for bugs 6124, 6125 and 6121
The apply rename optimizer step has been rewriten.
Apply optimizer now create new relational operators (doesn't steal
the structures, ie safe against referenced subqueries).
Date: 2016-11-17 14:37:34 +0100
From: Martin van Dinther <<martin.van.dinther>>
To: SQL devs <>
Version: 11.23.13 (Jun2016-SP2)
CC: @njnes
Last updated: 2016-12-21 13:06:56 +0100
Comment 24698
Date: 2016-11-17 14:37:34 +0100
From: Martin van Dinther <<martin.van.dinther>>
User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0
Build Identifier:
CASE WHEN NULL THEN 0 ELSE 1 END
returns different result from equivalent:
CASE WHEN IS NULL THEN 0 ELSE 1 END
Reproducible: Always
Steps to Reproduce:
CREATE TABLE table_two (this_column INTEGER);
INSERT INTO table_two VALUES (1);
INSERT INTO table_two VALUES (2);
INSERT INTO table_two VALUES (null);
SELECT * FROM table_two;
SELECT this_column, (CASE WHEN this_column IS NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
-- correct output
SELECT this_column, (CASE this_column WHEN NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
-- incorrect output for the NULL case
DROP TABLE table_two;
Actual Results:
Welcome to mclient, the MonetDB/SQL interactive terminal (unreleased)
Database: MonetDB v11.23.14 (unreleased), 'demo'
Type \q to quit, ? for a list of available commands
auto commit mode: on
sql>CREATE TABLE table_two (this_column INTEGER);
operation successful (30.384ms)
sql>INSERT INTO table_two VALUES (1);
1 affected row (7.501ms)
sql>INSERT INTO table_two VALUES (2);
1 affected row (8.050ms)
sql>INSERT INTO table_two VALUES (null);
1 affected row (8.038ms)
sql>SELECT * FROM table_two;
+-------------+
| this_column |
+=============+
| 1 |
| 2 |
| null |
+-------------+
3 tuples (0.475ms)
sql>SELECT this_column, (CASE WHEN this_column IS NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
+-------------+------------+
| this_column | new_column |
+=============+============+
| 1 | 1 |
| 2 | 1 |
| null | 0 |
+-------------+------------+
3 tuples (0.680ms)
sql>-- correct output
sql>SELECT this_column, (CASE this_column WHEN NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
+-------------+------------+
| this_column | new_column |
+=============+============+
| 1 | 1 |
| 2 | 1 |
| null | 1 |
+-------------+------------+
3 tuples (1.140ms)
sql>-- incorrect output for the NULL case
sql>DROP TABLE table_two;
operation successful (11.339ms)
Expected Results:
sql>SELECT this_column, (CASE WHEN this_column IS NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
+-------------+------------+
| this_column | new_column |
+=============+============+
| 1 | 1 |
| 2 | 1 |
| null | 0 |
+-------------+------------+
3 tuples (0.680ms)
sql>SELECT this_column, (CASE this_column WHEN NULL THEN 0 ELSE 1 END) AS new_column FROM table_two;
+-------------+------------+
| this_column | new_column |
+=============+============+
| 1 | 1 |
| 2 | 1 |
| null | 0 |
+-------------+------------+
3 tuples (1.140ms)
Comment 24699
Date: 2016-11-17 15:34:11 +0100
From: MonetDB Mercurial Repository <>
Changeset 1947e5ba7370 made by Martin van Dinther martin.van.dinther@monetdbsolutions.com in the MonetDB repo, refers to this bug.
For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=1947e5ba7370
Changeset description:
Comment 24751
Date: 2016-12-03 12:08:11 +0100
From: MonetDB Mercurial Repository <>
Changeset b72b05357cdd made by Niels Nes niels@cwi.nl in the MonetDB repo, refers to this bug.
For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=b72b05357cdd
Changeset description:
Comment 24754
Date: 2016-12-03 15:01:44 +0100
From: @njnes
when NULL != when IS NULL. The output output is correct, ie NULL IS NULL == TRUE while NULL != NULL == TRUE.
The text was updated successfully, but these errors were encountered: