Bug #4604 Stored Procedures: View definition with variable is incorrectly accepted
Submitted: 18 Jul 2004 22:35 Modified: 23 Jul 2004 2:47
Reporter: Trudy Pelzer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.1-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[18 Jul 2004 22:35] Trudy Pelzer
Description:
A stored procedure accepts a CREATE VIEW statement that uses a variable as the view definition, which is illegal syntax. If one attempts to create the same view outside of a stored procedure, MySQL correctly returns this error message:
ERROR 1349 (HY000): View's SELECT contains a variable or parameter)

Note the "How to repeat" statements below:
Although the CALL returns "OK", the first SELECT from the view returns this error:
ERROR 1064 (42000): You have an error in your SQL syntax; ....
which probably results from the fact that the view definition is really incomplete.

The second consecutive SELECT from the view crashes the server with this error message:
Packets out of order (Found: 2, expected 1)
ERROR 2013 (HY000): Lost connection to MySQL server during query

How to repeat:
delimiter //
create procedure p11 () begin declare v int; create view v as select v; end;//
call p11()//
select * from v//
ERROR 1064 (42000): You have an error in your SQL syntax; ...

select * from v//
Packets out of order (Found: 2, expected 1)
ERROR 2013 (HY000): Lost connection to MySQL server during query
[19 Jul 2004 19:05] Aleksey Kishkin
tested on slackware 9
[22 Jul 2004 15:05] Oleksandr Byelkin
ChangeSet 
  1.1725 04/07/22 16:04:30 bell@sanja.is.com.ua +4 -0 
  fixed SP variables detecting (BUG#4604) 
  fixed error handling
[23 Jul 2004 2:47] Oleksandr Byelkin
Thank you for bugreport! Bugfix is pushed to our source repository.