Bug #70359 Wrong result (missing rows) with group by, multi-part key, equality conditions
Submitted: 16 Sep 2013 23:02 Modified: 17 Sep 2013 7:07
Reporter: Elena Stepanova Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.1, 5.5, 5.6, 5.7 OS:Any
Assigned to: CPU Architecture:Any

[16 Sep 2013 23:02] Elena Stepanova
Description:
# This is a correct result:

SELECT b, a FROM t1 WHERE b = 'i' OR a = 2;
b	a
i	5
s	2
y	2

# This is an incorrect result:
SELECT b, max(a) FROM t1 WHERE b = 'i' OR a = 2 GROUP BY b;
b	max(a)
i	5

# Expected result for the 2nd query:
b	max(a)
i	5
s	2
y	2

How to repeat:
CREATE TABLE t1 (a INT, b VARCHAR(1), INDEX(b,a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (2,'s'),(5,'h'),(3,'q'),(1,'a'),(3,'v'),
(6,'u'),(7,'s'),(5,'y'),(1,'z'),(5,'i'),(2,'y');

SELECT b, max(a) FROM t1 WHERE b = 'i' OR a = 2 GROUP BY b;
[17 Sep 2013 7:07] MySQL Verification Team
Hello Elena,

Thank you for the bug report and test case.
Verified as described.

Thanks,
Umesh