Wrong result from a query with ALL subquery predicate in WHERE

Bug #993726 reported by Igor Babaev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
Fix Released
Critical
Oleksandr "Sanja" Byelkin

Bug Description

The following sequence of commands returns an incorrect result set in maridb-5.2:

CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (0);
SELECT 1 FROM t1 WHERE 1 > ALL(SELECT 1 FROM t1 WHERE a!=0);

MariaDB [test]> SELECT 1 FROM t1 WHERE 1 > ALL(SELECT 1 FROM t1 WHERE a!=0);
Empty set (0.00 sec)

(see also bug #12888306 for mysql code line)

Changed in maria:
status: New → Confirmed
importance: Undecided → Critical
assignee: nobody → Oleksandr "Sanja" Byelkin (sanja-byelkin)
milestone: none → 5.2
Changed in maria:
status: Confirmed → In Progress
Revision history for this message
Oleksandr "Sanja" Byelkin (sanja-byelkin) wrote :

1) The problem is not repeatable on mysql-test run.
2) it is repeatable om 5.1, 5.2, 5.3, 5.5

Revision history for this message
Oleksandr "Sanja" Byelkin (sanja-byelkin) wrote :

In mysql-test and mysql execution looks same and return_zero_rows called in both cases, so we probably have some other bug in mysql-test so it returns 1

Revision history for this message
Elena Stepanova (elenst) wrote :

If that's what you see in MTR output

CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (0);
SELECT 1 FROM t1 WHERE 1 > ALL(SELECT 1 FROM t1 WHERE a!=0);
1

it does not mean that mysqltest returns 1; '1' is the automatic column name here, while the result is empty. If it was returning a result, it would look like this:

SELECT 1 FROM t1;
1
1

Revision history for this message
Oleksandr "Sanja" Byelkin (sanja-byelkin) wrote :

The problem is that constant WHERE condition (the subquery) evaluates incorrectly to 0 in optimize_cond (in the SELECT list the subquery returns correct result - TRUE).

Revision history for this message
Oleksandr "Sanja" Byelkin (sanja-byelkin) wrote :

The problem is that in the subquery set do_send_rows so it does not send empty set in case of FALSE WHERE clause...

Changed in maria:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.