[MDEV-3339] LP:777654 - Wrong result with Aggregate + DISTINCT in FROM subquery in maria-5.3, 5.2 Created: 2011-05-05  Updated: 2015-02-02  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Philip Stoev (Inactive) Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug777654.xml    

 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  

--------------------------------------------------------------------+



 Comments   
Comment by Philip Stoev (Inactive) [ 2011-05-05 ]

Re: Wrong result with Aggregate + DISTINCT in FROM subquery in maria-5.2, 5.2
Also reproducible with MySQL 5.1.56

Comment by Rasmus Johansson (Inactive) [ 2012-02-20 ]

Launchpad bug id: 777654

Generated at Thu Feb 08 06:47:56 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.