Wrong result with OR + NOT NULL in maria-5.3
Bug #727667 reported by
Philip Stoev
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
High
|
Sergey Petrunia |
Bug Description
Not reproducible in maria-5.2. The following query:
SELECT * FROM t1 WHERE (f3 = 83) OR (f10 = 'q' AND f3 IS NULL);
returns
+------+------+
| f3 | f10 |
+------+------+
| NULL | r |
+------+------+
which is obviously wrong since neither f3 = 83 nor f10 = 'q'
test case:
CREATE TABLE t1 (
f3 int(11),
f10 varchar(1),
KEY (f3)
);
INSERT IGNORE INTO t1 VALUES ('9','k'
SELECT * FROM t1 WHERE (f3 = 83) OR (f10 = 'z' AND f3 IS NULL);
bzr version-info:
revision-id: <email address hidden>
date: 2011-03-01 10:22:22 +0300
build-date: 2011-03-02 11:45:01 +0200
revno: 2928
branch-nick: maria-5.3
Changed in maria: | |
milestone: | none → 5.3 |
tags: | added: regression |
Changed in maria: | |
assignee: | nobody → Sergey Petrunia (sergefp) |
Changed in maria: | |
status: | New → In Progress |
importance: | Undecided → High |
Changed in maria: | |
status: | In Progress → Fix Committed |
Changed in maria: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
In 5.3:
MariaDB [j28]> explain SELECT * FROM t1 WHERE (f3 = 83) OR (f10 = 'z' AND f3 IS NULL); ------- -----+- ------+ ------- ------+ ------- ------- -+----- -+----- ----+-- -----+- -----+- ------+ ------- -----+- ------+ ------- ------+ ------- ------- -+----- -+----- ----+-- -----+- -----+- ------+ ------- -----+- ------+ ------- ------+ ------- ------- -+----- -+----- ----+-- -----+- -----+- ------+
+----+-
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-
| 1 | SIMPLE | t1 | ref_or_null | f3 | f3 | 5 | const | 2 | |
+----+-
1 row in set (0.01 sec)
Note the lack of "Using where". Debugging shows that for_table( ).
- WHERE clause is indeed not checked.
- it is not there because it was removed by the "remove parts of WHERE that are guaranteed to be true by use of ref-access" functionality inside make_cond_