Bug #10821 Reserved words
Submitted: 24 May 2005 10:48 Modified: 24 Oct 2005 20:55
Reporter: Henning Andersen Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:4.1, odbc driver: 3.5.1.11 OS:Windows (XP SP2)
Assigned to: Peter Harvey CPU Architecture:Any

[24 May 2005 10:48] Henning Andersen
Description:
Hello,
I came across a problem with reserved words:
According to the documentation then neither of the names "db", "host" or "user" are reserved words whereas eg. "use" and "database" is.
Using odbc to create tables with these names leads to the following error message:

SQLGetDiagRec(0) code: 1005 msg: [MySQL][ODBC 3.51 Driver][mysqld-4.1.10a-nt]Can't create table '.\mysql\user.frm' (errno: -1), state: HYT00
COdbcConnection::WriteErrors at line 1266 in OdbcConnection.cpp

The state HYT00 refers to "login timeout" according to the odbc manual I got.

Either the names should be listed in the mysql documentation as reserved words and the error message should be proper, or the table names should be accepted.

The mysql documentation I got is for MySQL up to version 4.1.10.7
Creating tables with columns with these names is no problem.

I don't know if this also a problem outside of ODBC.

How to repeat:
Create tables with names being either: "db", "host" or "user" and it failes.
Changing the names to "dbx", hostx" and "userx" then it works!
[24 May 2005 15:31] Jim Winstead
Note that 'user', 'host', and 'db' tables should already exist in the 'mysql' database, as this is the database used for system tables. You should create a separate database for your data.

It does sound like Connector/ODBC is returning incorrect errors when trying to create a table with a name of one that already exists, however.
[25 May 2005 7:34] Aleksey Kishkin
SQLExecDirect() returns wrong error code.
Tested on Win 2000 Sp4 , Microsoft Visual C 7.0, MyODBC 3.51.11. Test case is attached.
[25 May 2005 7:34] Aleksey Kishkin
Test case

Attachment: test.c (text/plain), 3.76 KiB.

[24 Oct 2005 20:55] Peter Harvey
Repeated problem as per attached test file but there does not seem to be a bug here with reserved words. As Jim points out this is simply a problem when using mysql database - which people should avoid using for their own tables anyway. So perhaps a documentation issue.