Bug #23485 SELECT NULL IN (SELECT nothing) returns NULL instead of FALSE: unoptimized case
| Submitted: | 20 Oct 2006 1:01 | Modified: | 31 Oct 2006 22:47 |
|---|---|---|---|
| Reporter: | Sergey Petrunya | Email Updates: | |
| Status: | Duplicate | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
| Version: | 4.1 | OS: | |
| Assigned to: | Assigned Account | CPU Architecture: | Any |
| Tags: | IN, null, subquery | ||
[20 Oct 2006 1:01]
Sergey Petrunya
[20 Oct 2006 1:05]
Sergey Petrunya
Analysis1:
The subquery is evaluated using class Item_in_optimizer::val_int(). The comment for that function says:
/*
Item_in_optimizer item is special boolean function. On value request
(one of val, val_int or val_str methods) it evaluate left expression
of IN by storing it value in cache item (one of Item_cache* items),
then it test cache is it NULL. If left expression (cache) is NULL then
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Item_in_optimizer return NULL, else it evaluate Item_in_subselect.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
The code follows the comment. The part marked with ^^^ is incorrect, as
NULL IN (SELECT * FROM empty_rowset) should be FALSE.
[20 Oct 2006 20:43]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/14098 ChangeSet@1.2533, 2006-10-21 00:48:40+04:00, sergefp@mysql.com +5 -0 BUG#23485: wrong result for "SELECT NULL IN (SELECT nothing)", direct subquery execution case - Make the direct subquery execution engine to evaluate NULL IN (SELECT ...) in a special way that produces correct results. Note: This breaks [unique_]index_subquery, will fix in forthcoming commit.
[31 Oct 2006 21:03]
Igor Babaev
Patch is to be applied only to 5.0->5.1.
[31 Oct 2006 22:47]
Sergey Petrunya
This bug is fixed by fix for BUG#8804.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.