[MDEV-609] LP:993718 - Wrong result from a query with GROUP BY, ORDER BY and LIMIT Created: 2012-05-03  Updated: 2012-10-31  Resolved: 2012-10-31

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.5.28a, 5.3.10, 5.2.13

Type: Bug Priority: Major
Reporter: Igor Babaev Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug993718.xml    

 Description   

The following sequence of commands gives a wrong result set:

CREATE TABLE t1 (
id BIGINT(20) , member_id_to INT(11) , r_date DATE ,
PRIMARY KEY (id,r_date), KEY r_date_idx (r_date), KEY t1_idx01 (member_id_to)
) ENGINE=InnoDB;

INSERT INTO t1 VALUES
(107924526,518491,'2011-05-01'), (107924527,518491,'2011-05-01'), (107924528,518491,'2011-05-01'),
(107924529,518491,'2011-05-01'), (107924530,518491,'2011-05-01'), (107924531,518491,'2011-05-01'),
(107924532,518491,'2011-05-01'), (107924534,518491,'2011-06-21'), (107924535,518491,'2011-06-21'), (107924536,518491,'2011-06-21'), (107924537,518491,'2011-06-21'), (107924538,518491,'2011-06-21'),
(107924542,1601319,'2011-06-21'), (107924543,1601319,'2011-06-21'), (107924544,1601319,'2011-06-21'),
(107924545,1601319,'2011-06-21'), (107924546,1601319,'2011-06-21'), (107924547,1601319,'2011-06-21'),
(107924548,1601319,'2011-06-21'), (107924549,1601319,'2011-06-21'), (107924550,1601319,'2011-06-21');

SELECT member_id_to, COUNT FROM t1
WHERE r_date = '2011-06-21' GROUP BY member_id_to ORDER BY 2 LIMIT 1;

MariaDB [test]> SELECT member_id_to, COUNT FROM t1 WHERE r_date = '2011-06-21' GROUP BY member_id_to ORDER BY 2 LIMIT 1;
----------------------+

member_id_to COUNT

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

NULL 2

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

(see also bug #12713907 reported for mysql-5.1)



 Comments   
Comment by Rasmus Johansson (Inactive) [ 2012-05-10 ]

Launchpad bug id: 993718

Comment by Vladislav Vaintroub [ 2012-10-30 ]

Can't reproduce in any of 5.2,5.3,5.5

Comment by Igor Babaev [ 2012-10-31 ]

This bug can be reproduced with mariadb- 5.2 rev 3163, but cannot be reproduced with mariadb-5.2 rev 3164.
Apparently it was fixed by the patch for Oracle's bug #12713907 that was pulled into mariadb-5.2 from mysql-5.1 on 2012-08-22.

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