Bug #2205 USE database doesn't work after DROP database + CREATE database
Submitted: 24 Dec 2003 8:52 Modified: 7 Sep 2004 12:54
Reporter: Georg Richter Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1.2 OS:Linux (Linux)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[24 Dec 2003 8:52] Georg Richter
Description:
If you drop a database and recreate it, USE database doesn't work.

How to repeat:
georg@beethoven:~/work/mysql/mysql-4.1> /usr/local/mysql-4.1/bin/mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.2-alpha-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> drop database test;
Query OK, 1 row affected (0.03 sec)

mysql> create database test;
Query OK, 1 row affected (0.00 sec)

mysql> use test;
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| NULL       |
+------------+
1 row in set (0.00 sec)
[24 Dec 2003 9:01] Dean Ellis
Verified (actually crashed for me), though only if the dropped database was active at the time:

USE test;
DROP DATABASE test;
CREATE DATABASE test;
USE test;
SELECT DATABASE();
[25 Dec 2003 11:25] MySQL Verification Team
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:
[5 Jan 2004 11:59] Jani Tolonen
Fixed.

Regards,
Jani
[2 Sep 2004 18:15] Konstantin Osipov
The bug still happens when 4.0 client connects to 4.1 database.
The fix for some reason didn't go to 4.0.

kostja@oak:~> mysql test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.5-gamma-valgrind-max-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> drop database test;
Query OK, 1 row affected (0.06 sec)

mysql> create database test;
Query OK, 1 row affected (0.00 sec)

mysql> use test;
Database changed
mysql> create table t1 (a int);
ERROR 1046: No database selected
mysql> select version();
+--------------------------------+
| version()                      |
+--------------------------------+
| 4.1.5-gamma-valgrind-max-debug |
+--------------------------------+
1 row in set (0.12 sec)

mysql>
[7 Sep 2004 12:54] Ramil Kalimullin
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