Bug #52873 ";" misinterpreted for USE statement if delimiter was changed
Submitted: 15 Apr 2010 22:52 Modified: 15 Apr 2010 23:42
Reporter: Roel Van de Paar Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.1.45, 5.0.83 OS:Any
Assigned to: Davi Arnaut CPU Architecture:Any

[15 Apr 2010 22:52] Roel Van de Paar
Description:
mysql> DELIMITER //
mysql> USE TRIG;
ERROR 1049 (42000): Unknown database 'trig;'
mysql> SELECT 1;
    -> //
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

How to repeat:
DELIMITER //
USE TRIG;

Suggested fix:
Still allow ; for USE when DELIMITER was used.
[15 Apr 2010 22:57] Roel Van de Paar
Verified in 5.0.83 as well

mysql> delimiter //
mysql> use mysql;
ERROR 1049 (42000): Unknown database 'mysql;'
[15 Apr 2010 23:42] Davi Arnaut
USE is a mysql client command. For example, a "tee foo; tee bar;" command won't work as intended if the delimiter is not semicolon. It works for SELECT (and any SQL) because the string is sent to the server where it is parsed as a multiple statement (always separated by semicolon) -- SELECT is not a mysql client command.
[15 Apr 2010 23:52] Roel Van de Paar
Davi, that makes perfect sense. Thanks for clarifying.