Bug #150 Server crash with user vars in UNION
Submitted: 14 Mar 2003 2:23 Modified: 14 Mar 2003 4:31
Reporter: Georg Richter Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1 OS:Linux (Linux)
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[14 Mar 2003 2:23] Georg Richter
Description:
When using user vars (as shown below) in UNION, server crashes.

How to repeat:
mysql> SELECT @a:=1 UNION SELECT @a:=@a+1 
ERROR 2013: Lost connection to MySQL server during query
[14 Mar 2003 2:28] Georg Richter
to simplify it:

SELECT @a:=1 UNION SELECT @b:=2
[14 Mar 2003 4:31] Oleksandr Byelkin
sql/sql_lex.h:          1.124 1.125 bell 03/03/14 10:31:25 (modified, 
needs delta) 
 
@@ -501,11 +501,13 @@ 
       but we should merk all subselects as uncacheable from current till 
       most upper 
     */ 
-    for (SELECT_LEX_NODE *sl= current_select; 
-	 sl != &select_lex; 
-	 sl= sl->outer_select()) 
+    SELECT_LEX_NODE *sl; 
+    SELECT_LEX_UNIT *un; 
+    for (sl= current_select, un= sl->master_unit(); 
+	 un != &unit; 
+	 sl= sl->outer_select(), un= sl->master_unit()) 
     { 
-      sl->uncacheable = sl->master_unit()->uncacheable= 1; 
+      sl->uncacheable = un->uncacheable= 1; 
     } 
   } 
 } LEX;