Bug #2805 USE and ROLLBACK combination fails within stored procedure
Submitted: 15 Feb 2004 8:58 Modified: 23 Mar 2004 8:36
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.0-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Per-Erik Martin CPU Architecture:Any

[15 Feb 2004 8:58] Peter Gulutzan
Description:
Make two stored procedures (one calling the other) and put USE and ROLLBACK 
statements in them. Make sure that one of the USEd databases doesn't exist. 
Call the main procedure three times. The result is "packets out of order". 
 

How to repeat:
pgulutzan@aijj42nay42q9:~> /usr/local/mysql/bin/mysql --user=root 
Welcome to the MySQL monitor.  Commands end with ; or \g. 
Your MySQL connection id is 9 to server version: 5.0.0-alpha-debug 
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer. 
 
mysql> delimiter // 
mysql> create database db81// 
Query OK, 1 row affected (0.00 sec) 
 
mysql> create procedure p81 () begin use db81; call p82(); rollback; end;// 
Query OK, 0 rows affected (0.30 sec) 
 
mysql> create procedure p82 () begin use db82; rollback; end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call p81()// 
ERROR 1049 (42000): Unknown database 'db82' 
mysql> call p81()// 
ERROR 1049 (42000): Unknown database 'db82' 
mysql> call p81()// 
Packets out of order (Found: 2, expected 1) 
ERROR 2013 (HY000): Lost connection to MySQL server during query 
mysql>
[23 Mar 2004 8:36] Per-Erik Martin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

This is no longer repeatable.
(USE inside a stored procedure is no longer allowed, since it never actually
worked properly, and sinceit definitely wouldn't work now with procedures
belonging to a DB.)