Bug #18202 use database command doesn't select database
Submitted: 14 Mar 2006 0:18 Modified: 14 Mar 2006 0:36
Reporter: HOTorNOT Tech Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.15 OS:Fedore Core 4
Assigned to: MySQL Verification Team CPU Architecture:Any

[14 Mar 2006 0:18] HOTorNOT Tech
Description:
This is a bug with the use database command to select the active database. It possibly involves the mysql client and not the server. 

It seems to happen only with databases whose name is 3 or less characters long. The command: 

> use aaa; 

Returns an Unknown database error. However the command

> use aaa

Without the semicolon, will work. On a database name with 4 or more characters  will work in both cases. 

> use test; #works
> use test  #without semicolon also works. 

How to repeat:
Step 1: use a clean install of mysql 5.0.15
Step 2: go into mysql as user root. 
Step 3: > create database aaa;
Step 4: > show databases;        #verify the db has been created. 
Step 5: > use database aaa;      #you should get the unknown database error.
Step 6: > use database aaa       #no semicolon. this should work (mysteriously)
Step 7: > use database test;     # just to see that the syntax of the command is technically right. 

Suggested fix:
Looks like some kind of string length or equality problem.
[14 Mar 2006 0:22] HOTorNOT Tech
Transcript of bug

Attachment: test.txt (text/plain), 978 bytes.

[14 Mar 2006 0:36] MySQL Verification Team
Thank you for the bug report. Please update your server version for the
current release. That bug was already fixed. Thanks in advance.

miguel@hegel:~/dbs/5.0> bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.20-debug

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

mysql> use aaa;
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| aaa        |
+------------+
1 row in set (0.00 sec)

mysql>