Bug #6406 DISTINCT + SUBQUERY + ORDER BY crashes server
Submitted: 3 Nov 2004 17:07 Modified: 3 Dec 2004 23:05
Reporter: Georg Richter Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.8 + 5.0.2 OS:Linux (Linux)
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[3 Nov 2004 17:07] Georg Richter
Description:
This bug looks very similar to #6303, but #6303 didn't crash under 4.1.8 

How to repeat:
4.1.8-debug-log 
[18:02] root@test> create table t1 (a int, b int); 
Query OK, 0 rows affected (0.10 sec) 
 
4.1.8-debug-log 
[18:02] root@test> create table t2 (a int, b int); 
Query OK, 0 rows affected (0.12 sec) 
 
4.1.8-debug-log 
[18:02] root@test> insert into t1 values (1,1),(1,2),(1,3),(2,4),(2,5); 
Query OK, 5 rows affected (0.03 sec) 
Records: 5  Duplicates: 0  Warnings: 0 
 
4.1.8-debug-log 
[18:02] root@test> insert into t2 values (1,3),(2,1); 
Query OK, 2 rows affected (0.03 sec) 
Records: 2  Duplicates: 0  Warnings: 0 
 
4.1.8-debug-log 
[18:02] root@test> select distinct a,b, (select max(b) from t2 where t1.b=t2.a) from 
t1 order by t1.b; 
ERROR 2013 (HY000): Lost connection to MySQL server during query 
4.1.8-debug-log 
[18:02] root@test> 

Suggested fix:
[3 Nov 2004 17:36] MySQL Verification Team
Verified on latest BK source 5.0
[15 Nov 2004 22:17] Oleksandr Byelkin
ChangeSet 
  1.2107 04/11/16 00:16:04 bell@sanja.is.com.ua +4 -0 
  fixed joincleunup to avoid double deletin tables, and too earlyfull cleanup in case of 
EXPLAIN 
  fixed cleunup of TMP_TABLE_PARAM 
  (BUG#6406)
[3 Dec 2004 23:05] Oleksandr Byelkin
Thank you for bugreport, Bug is fixed and patch is pushed to our source repository.