Bug #4400 incorrect error message about aggregate function in subquery
Submitted: 3 Jul 2004 20:52 Modified: 17 Jul 2004 1:42
Reporter: Oleksandr Byelkin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1 OS:Any (all)
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[3 Jul 2004 20:52] Oleksandr Byelkin
Description:
incorrect error message about aggregate function in subquery 
query 'select t000.a, count(*) `C` FROM t1 t000 GROUP BY t000.a HAVING C > ALL 
(SELECT count(*) FROM t2 t001 WHERE t001.a=1)' failed: 1111: Invalid use of group 
function 
 

How to repeat:
CREATE TABLE `t1` ( `a` int(11) default NULL) ENGINE=MyISAM DEFAULT 
CHARSET=latin1; 
insert into t1 values (1); 
CREATE TABLE `t2` ( `b` int(11) default NULL, `a` int(11) default NULL) 
ENGINE=MyISAM DEFAULT CHARSET=latin1; 
insert into t2 values (1,2); 
select t000.a, count(*) `C` FROM t1 t000 GROUP BY t000.a HAVING count(*) > ALL 
(SELECT count(*) FROM t2 t001 WHERE t001.a=1);
[4 Jul 2004 7:48] Oleksandr Byelkin
ChangeSet 
  1.1961 04/07/04 08:46:28 bell@sanja.is.com.ua +5 -0 
  aggregate functions check during substitution made only for single row subselects 
(BUG#4400) 
  restoring current senect pointer before PS rexecution (backport from 5.0) 
  removed spaces at  lines ends
[17 Jul 2004 1:13] Oleksandr Byelkin
pushed