Bug #6797 Stored procedure won't allow union in subquery
Submitted: 24 Nov 2004 14:43 Modified: 21 May 2005 9:59
Reporter: Peter Gulutzan Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.2-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Assigned Account CPU Architecture:Any

[24 Nov 2004 14:43] Peter Gulutzan
Description:
An assignment of the form "SET target = (SELECT ... UNION SELECT ...)" might fail at 
runtime, but that's not known for certain in advance. Therefore such statements should be 
allowed inside stored procedures. They are allowed outside stored procedures. 
 
 

How to repeat:
mysql> create table t45 (s1 int);// 
Query OK, 0 rows affected (0.28 sec) 
 
mysql> create procedure p45 (pout int) set pout = (select s1 from t45 union select s1 from 
t45);// 
ERROR 1221 (HY000): Incorrect usage of UNION and INTO 
mysql> set @pout = (select s1 from t45 union select s1 from t45);// 
Query OK, 0 rows affected (0.00 sec)
[17 Dec 2004 20:54] Sergey Petrunya
The error is produced in sql_yacc.yy, at place where LEX::exchange is compared with NULL. It is not NULL but it seems to be filled with 'unitialized data'.
When I tried to fix it I bumped into a broader problem - BUG#7394, so this bug is not likely to be fixed until BUG#7394 is fixed.
[21 May 2005 9:59] Sergey Petrunya
This bug is a duplicate of BUG#5963 and is fixed by the fix for that bug.