Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.1.18, 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
-
None
-
OS X El Capitan, MariaDB installed through Homebrew
-
10.0.30
Description
I'm confused by the behaviour of `NULL` in a `NOT IN` expression. (MariaDB 10.1.18):
MariaDB [(none)]> select 1 from dual where null not in (1);
|
Empty set (0.00 sec)
|
|
MariaDB [(none)]> select 1 from dual where null not in (select 1);
|
Empty set (0.00 sec)
|
|
MariaDB [(none)]> select 1 from dual where null not in (select 1 from dual);
|
Empty set (0.00 sec)
|
This is as I expected, since `NULL` is not equal or unequal to anything.
MariaDB [(none)]> select 1 from dual where null not in (select 1 from mysql.user);
|
+---+
|
| 1 |
|
+---+
|
| 1 |
|
+---+
|
1 row in set (0.00 sec)
|
Huh? How can that be? Maybe it's because I can't read the mysql.user table?
MariaDB [(none)]> select distinct 1 from mysql.user;
|
+---+
|
| 1 |
|
+---+
|
| 1 |
|
+---+
|
1 row in set (0.00 sec)
|
No, it returns a value. When selecting the one from a actual table, not `dual`, or an inline list expression, the behaviour is different.
Is this a bug in MariaDB? An old MySQL server (5.5.40) I tried this with gave the expected empty set for all queries.
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Description |
I'm confused by the behaviour of `NULL` in a `NOT IN` expression. (MariaDB 10.1.18):
MariaDB [(none)]> select 1 from dual where null not in (1); Empty set (0.00 sec) MariaDB [(none)]> select 1 from dual where null not in (select 1); Empty set (0.00 sec) MariaDB [(none)]> select 1 from dual where null not in (select 1 from dual); Empty set (0.00 sec) This is as I expected, since `NULL` is not equal or unequal to anything. MariaDB [(none)]> select 1 from dual where null not in (select 1 from mysql.user); +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) Huh? How can that be? Maybe it's because there are several rows with value `1` in the subquery: MariaDB [(none)]> select 1 from dual where null not in (select distinct 1 from mysql.user); +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) No, doesn't matter. When selecting the one from a actual table, not `dual`, the behaviour is different. Is this a bug in MariaDB? An old MySQL server (5.5.40) I tried this with gave the expected empty set for all queries. |
I'm confused by the behaviour of `NULL` in a `NOT IN` expression. (MariaDB 10.1.18):
{noformat} MariaDB [(none)]> select 1 from dual where null not in (1); Empty set (0.00 sec) MariaDB [(none)]> select 1 from dual where null not in (select 1); Empty set (0.00 sec) MariaDB [(none)]> select 1 from dual where null not in (select 1 from dual); Empty set (0.00 sec) {noformat} This is as I expected, since `NULL` is not equal or unequal to anything. {noformat} MariaDB [(none)]> select 1 from dual where null not in (select 1 from mysql.user); +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) {noformat} Huh? How can that be? Maybe it's because there are several rows with value `1` in the subquery: {noformat} MariaDB [(none)]> select 1 from dual where null not in (select distinct 1 from mysql.user); +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) {noformat} No, doesn't matter. When selecting the one from a actual table, not `dual`, the behaviour is different. Is this a bug in MariaDB? An old MySQL server (5.5.40) I tried this with gave the expected empty set for all queries. |
Description |
I'm confused by the behaviour of `NULL` in a `NOT IN` expression. (MariaDB 10.1.18):
{noformat} MariaDB [(none)]> select 1 from dual where null not in (1); Empty set (0.00 sec) MariaDB [(none)]> select 1 from dual where null not in (select 1); Empty set (0.00 sec) MariaDB [(none)]> select 1 from dual where null not in (select 1 from dual); Empty set (0.00 sec) {noformat} This is as I expected, since `NULL` is not equal or unequal to anything. {noformat} MariaDB [(none)]> select 1 from dual where null not in (select 1 from mysql.user); +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) {noformat} Huh? How can that be? Maybe it's because there are several rows with value `1` in the subquery: {noformat} MariaDB [(none)]> select 1 from dual where null not in (select distinct 1 from mysql.user); +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) {noformat} No, doesn't matter. When selecting the one from a actual table, not `dual`, the behaviour is different. Is this a bug in MariaDB? An old MySQL server (5.5.40) I tried this with gave the expected empty set for all queries. |
I'm confused by the behaviour of `NULL` in a `NOT IN` expression. (MariaDB 10.1.18):
{noformat} MariaDB [(none)]> select 1 from dual where null not in (1); Empty set (0.00 sec) MariaDB [(none)]> select 1 from dual where null not in (select 1); Empty set (0.00 sec) MariaDB [(none)]> select 1 from dual where null not in (select 1 from dual); Empty set (0.00 sec) {noformat} This is as I expected, since `NULL` is not equal or unequal to anything. {noformat} MariaDB [(none)]> select 1 from dual where null not in (select 1 from mysql.user); +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) {noformat} Huh? How can that be? Maybe it's because I can't read the mysql.user table? {noformat} MariaDB [(none)]> select distinct 1 from mysql.user; +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) {noformat} No, it returns a value. When selecting the one from a actual table, not `dual`, or an inline list expression, the behaviour is different. Is this a bug in MariaDB? An old MySQL server (5.5.40) I tried this with gave the expected empty set for all queries. |
Status | Open [ 1 ] | Confirmed [ 10101 ] |
Fix Version/s | 5.5 [ 15800 ] | |
Fix Version/s | 10.0 [ 16000 ] | |
Fix Version/s | 10.1 [ 16100 ] | |
Fix Version/s | 10.2 [ 14601 ] | |
Affects Version/s | 5.5 [ 15800 ] | |
Affects Version/s | 10.0 [ 16000 ] | |
Affects Version/s | 10.1 [ 16100 ] | |
Affects Version/s | 10.2 [ 14601 ] | |
Assignee | Sergei Petrunia [ psergey ] |
Assignee | Sergei Petrunia [ psergey ] | Varun Gupta [ varun ] |
Status | Confirmed [ 10101 ] | In Progress [ 3 ] |
Sprint | 10.0.30 [ 140 ] |
Priority | Minor [ 4 ] | Major [ 3 ] |
Assignee | Varun Gupta [ varun ] | Sergei Petrunia [ psergey ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Assignee | Sergei Petrunia [ psergey ] | Varun Gupta [ varun ] |
Assignee | Varun Gupta [ varun ] | Sergei Petrunia [ psergey ] |
Assignee | Sergei Petrunia [ psergey ] | Varun Gupta [ varun ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Status | Stalled [ 10000 ] | In Progress [ 3 ] |
Assignee | Varun Gupta [ varun ] | Sergei Petrunia [ psergey ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Fix Version/s | 5.5.55 [ 22311 ] | |
Fix Version/s | 10.2 [ 14601 ] | |
Fix Version/s | 5.5 [ 15800 ] | |
Fix Version/s | 10.0 [ 16000 ] | |
Fix Version/s | 10.1 [ 16100 ] | |
Assignee | Sergei Petrunia [ psergey ] | Varun Gupta [ varun ] |
Resolution | Fixed [ 1 ] | |
Status | In Review [ 10002 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 77893 ] | MariaDB v4 [ 151084 ] |
Thanks for the report and test case.