Bug #24618 The extended table-specification "database.table" in SQL creates errors
Submitted: 27 Nov 2006 11:37 Modified: 27 Nov 2006 12:47
Reporter: Winfried Kaiser Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4/5 OS:Windows (XP Pro)
Assigned to: CPU Architecture:Any

[27 Nov 2006 11:37] Winfried Kaiser
Description:
The extended table-specification "database.table" creates errors, if the the "database"-name contains a "-" (dash);

The error is:

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-olc.olc_configuration' at line 1"

A sample statement is "select count(*) from db1021924-olc.olc_configuration"

A connect the the database "db1021924-olc" is possible (with PHP), but queries using the the extended table-specifications fail!

As we are using a "multi-db" approach in our application, and the ISP dictates this type of database-name syntax, this is a real show-stopper!

A database-name like "db1021924_olc" (using the underscore instead of the dash) works fine!

How to repeat:
Create a database named "db1021924-olc" and query it, using the extended table-specification

Suggested fix:
Allow "dash" in table-names for SQL-queries.
[27 Nov 2006 12:47] MySQL Verification Team
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.27-community-nt

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

mysql> create database `db1021924-olc`;
Query OK, 1 row affected (0.00 sec)

mysql> use `db1021924-olc`;
Database changed
mysql> create table tb1 (id serial, col2 char(10));
Query OK, 0 rows affected (0.13 sec)

mysql> insert into tb1 (col2) values ("hello")
    -> ;
Query OK, 1 row affected (0.03 sec)

mysql> select * from `db1021924-olc`.tb1;
+----+-------+
| id | col2  |
+----+-------+
|  1 | hello |
+----+-------+
1 row in set (0.00 sec)

mysql>