Bug #8025 correlated subquerry in all might crash server
Submitted: 19 Jan 2005 22:31 Modified: 4 Feb 2005 20:52
Reporter: Martin Friebe (Gold Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.9/ BK source OS:FreeBSD (freebsd)
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[19 Jan 2005 22:31] Martin Friebe
Description:
see how to repeat.

it is important that the server is strted up fresh.

I am running mysql 4.1.9-log compiled from freebsd port on freebsd 4.10

In addition: is the last error msg in the examples ok? where is the group function?

How to repeat:
# stop and start your server.

 select 1 = ALL (  select 1 from t1 where 1 = xx ), 1 as xx ;
# server crash

#now run 
 select 1 as xx, 1 = ALL (  select 1 from t1 where 1 = xx )  ;
+----+--------------------------------------------+
| xx | 1 = ALL (  select 1 from t1 where 1 = xx ) |
+----+--------------------------------------------+
|  1 |                                          1 |
+----+--------------------------------------------+
# which is fine

from now on:
select 1 = ALL (  select 1 from t1 where 1 = xx ), 1 as xx ;
ERROR 1247 (42S22): Reference 'xx' not supported (reference on group function)

Suggested fix:
-
[19 Jan 2005 22:35] Martin Friebe
create  table t1 (a integer); insert into t1 values (1);

 select  1 = any (  select 1 from t1 where 1 = xx ) , 1 as xx from t1;

# crashes always

# and
# first to avoid the crash
select 1 xx,  1 = any (  select 1 from t1 where 1 = xx )  from DUAL;

 select  1 = any (  select 1 from t1 where 1 = xx ) , 1 as xx from DUAL;
ERROR 1247 (42S22): Reference 'xx' not supported (forward reference in item list)

# much more meaningfull error
[19 Jan 2005 22:39] MySQL Verification Team
Thank you for the bug report I was able to repeat on Slackware box
with BK source.
[24 Jan 2005 15:19] Oleksandr Byelkin
ChangeSet
  1.2166 05/01/24 17:17:19 bell@sanja.is.com.ua +4 -0
  fixed way of forward reference detection to support literal constant (BUG#8025)
[1 Feb 2005 12:05] Oleksandr Byelkin
Thank you for bugreport. Bugfix is pushed into 4.1.10 (5.0.3) source repository
[4 Feb 2005 20:52] Paul DuBois
Mentioned in 4.1.10 and 5.0.3 change notes.