Bug #14535 SQL cannot be used for field name
Submitted: 1 Nov 2005 6:57 Modified: 1 Nov 2005 7:54
Reporter: Wai Wong Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.15 OS:Any (all)
Assigned to: CPU Architecture:Any

[1 Nov 2005 6:57] Wai Wong
Description:
In 4.1.x, the following statement:

mysql> select SQL from testTable;

is ok, where SQL is a field in testTable;

Now, in 5.0.15, the following error is reported:

ERROR 1064 (42000): 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 'SQL from testTable' at line 1

According to the syntax of "SELECT", this is a valid statement.  Seems that the parser is anticipating SQL_XXX and hence report an error.

How to repeat:
See description

Suggested fix:
Fix the parser.
[1 Nov 2005 7:54] MySQL Verification Team
Hello Wai Wong,

Thank you for the report, but this is not a bug. SQL is a reserved word in MySQL.
http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
[1 Nov 2005 7:59] Wai Wong
Thanks.  It is surprising to have such a common word to become a reserved word, while we cannot find any special usage for it.  I am afriad there may be quite some databases/code needs changing especially this is working before 5.0

Anyway, thanks for the prompt response.

Wai Wong.
[1 Nov 2005 16:02] Paul DuBois
Remember that you can use the identifier SQL if you
really want to, if you quote it properly.  For example:

SELECT `SQL` FROM ...

See:
http://dev.mysql.com/doc/refman/5.0/en/legal-names.html