Submitted: 5 Sep 2003 23:04 Modified: 10 Sep 2003 3:56
Reporter: Georg Richter Email Updates:
Status: Closed Impact on me:
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.15 (maybe all) OS:Linux (Linux)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[5 Sep 2003 23:04] Georg Richter
I detected the following (incorrect) behaviour.

When no database is selected SELECT DATABASE() returns 1 row with empty string.
That should be 0 rows, or at least NULL instead of an empty string.

When you select and drop a database SELECT DATABASE() still returns the dropped database.

How to repeat:
vivaldi:/usr/local/mysql-4.0.15-debug # bin/mysql -uroot;
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 4.0.15-debug

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

mysql> select database();
| database() |
|            |
1 row in set (0.00 sec)

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

mysql> use foo;
Database changed

mysql> drop database foo;
Query OK, 0 rows affected (0.00 sec)

mysql> select database();
| database() |
| foo        |
1 row in set (0.00 sec)
[10 Sep 2003 3:56] 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
[13 Jan 2011 5:47] Nikita Dalwadi
hi guy,

 one question , how can we connect database which is passed from variable.

 i want some thing like in script which allws me to select database.

  Set @DBName ='xyz';
  select database(@DBNAME)

 This doesn't work 
i tried with prepare and execute bust still it down't work...

Prepare stm1 from 'Use ?';
Set @DBName = 'xyz';
Execute stm1 using @DBName;

could someone plz help me in solving this....