Wrong result with Aggregate + DISTINCT in FROM subquery in maria-5.3, 5.2

Bug #777654 reported by Philip Stoev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
Fix Released
High
Igor Babaev

Bug Description

Reproducible in maria-5.3, maria-5.2. Not reproducible in MySQL 5.5 .

The following query:

SELECT * FROM ( SELECT SUM( DISTINCT f11 ) FROM t1) AS a1;

returns (0) even though the FROM subquery returns (NULL);

Test case:

USE test;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( f11 int NOT NULL ) ;
SELECT * FROM ( SELECT SUM( DISTINCT f11 ) FROM t1) AS a1;

explain in maria 5.3:

+----+-------------+------------+--------+---------------+------+---------+------+------+--------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+--------+---------------+------+---------+------+------+--------------------------------+
| 1 | PRIMARY | <derived2> | system | NULL | NULL | NULL | NULL | 1 | |
| 2 | DERIVED | NULL | NULL | NULL | NULL | NULL | NULL | NULL | no matching row in const table |
+----+-------------+------------+--------+---------------+------+---------+------+------+--------------------------------+

explain in mysql 5.5:

+----+-------------+------------+--------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+--------+---------------+------+---------+------+------+-------+
| 1 | PRIMARY | <derived2> | system | NULL | NULL | NULL | NULL | 1 | |
| 2 | DERIVED | t1 | ALL | NULL | NULL | NULL | NULL | 1 | |
+----+-------------+------------+--------+---------------+------+---------+------+------+-------+

Changed in maria:
milestone: none → 5.2
assignee: nobody → Igor Babaev (igorb-seattle)
Changed in maria:
milestone: 5.2 → 5.3
milestone: 5.3 → 5.2
Revision history for this message
Philip Stoev (pstoev-askmonty) wrote :

Also reproducible with MySQL 5.1.56

summary: - Wrong result with Aggregate + DISTINCT in FROM subquery in maria-5.2,
+ Wrong result with Aggregate + DISTINCT in FROM subquery in maria-5.3,
5.2
Changed in maria:
status: New → Confirmed
importance: Undecided → High
Changed in maria:
status: Confirmed → In Progress
Changed in maria:
status: In Progress → Fix Committed
Changed in maria:
status: Fix Committed → 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.