Bug #28383 A table named 'div'
Submitted: 11 May 2007 19:23 Modified: 11 May 2007 21:52
Reporter: Simon Forsberg Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version: OS:Linux (Debian)
Assigned to: CPU Architecture:Any

[11 May 2007 19:23] Simon Forsberg
Description:
After having mysql 3.23 for a while, it was now time for an update to 5.0. There was also a new stable Debian release for the system so there was many updates taken at once.

However, in the old mysql version the word 'div' was not reserved, so it was no problems to have a table with that name. But now, with mysql 5.0, I can't do ANY of the following statements:
SELECT * FROM div;
RENAME TABLE div TO div2;
DROP TABLE div;

How to repeat:
Make a table named 'div' in mysql 3.23, update to 5.0 and then try to use that table.

Suggested fix:
Allow tables with the name 'div', or give me a chance to rename the table
[11 May 2007 20:53] Paul DuBois
Because DIV is now a reserved word, you can use it as an identifier by quoting it as `DIV`.

Each manual has a section that indicates which words are new reserved words for the MySQL series to which the manual applies:

http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html
http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

These sections also discuss the identifier-quoting rules.
[11 May 2007 21:52] MySQL Verification Team
Thank you for the bug report.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.42-debug Source distribution

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

mysql> create table `div` (id serial);
Query OK, 0 rows affected (0.02 sec)

mysql> insert into `div` values (null);
Query OK, 1 row affected (0.00 sec)

mysql> select * from `div`;
+----+
| id |
+----+
|  1 | 
+----+
1 row in set (0.00 sec)

mysql> rename table `div` to div2;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from div2;
+----+
| id |
+----+
|  1 | 
+----+
1 row in set (0.00 sec)

mysql>