Bug #60621 RENAME TABLE does not honour 'lower_case_table_name' setting
Submitted: 24 Mar 2011 15:23 Modified: 24 Mar 2011 18:22
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.56 OS:Microsoft Windows (7 - probably MAC too)
Assigned to: CPU Architecture:Any
Tags: qc

[24 Mar 2011 15:23] Peter Laursen
One more example of MySQL code written without considering 'lower_case_table_name' variable

How to repeat:
SHOW VARIABLES LIKE 'lower_case_table_names'; -- 2
SHOW CREATE TABLE BlahBlih; -- CREATE TABLE `BlahBlih` etc. - note *mixed case* here
RENAME TABLE BlahBlih TO blahblih; -- Error Code : 1050: Table 'blahblih' already exists

Suggested fix:
Consider the setting of the variable before throwing the error. Don't rely on File System. 

Workaround is of course to 'push in' one more RENAME TO `blahbluh`.
[24 Mar 2011 16:16] Peter Laursen
Yo umay of course add subcategory 'options' or 'ddl' or whatever as you want. I am not quite sure where to put it.
[24 Mar 2011 17:27] Valeriy Kravchuk
Sorry, but our manual (http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_lower_case_tabl...), says:

"If set to 2, table names are stored as given but compared in lowercase."

So, what is the bug here?
[24 Mar 2011 18:06] Peter Laursen
The documentaation says hwo it is *btored* - not how it is *named*.  In the case it is *named* in mixed case - ergo RE*NAME* changing lettercase should be valid in my understanding.
[24 Mar 2011 18:07] Peter Laursen
sorry .. typo!  *btored* >> *stored*
[24 Mar 2011 18:22] Valeriy Kravchuk
It is important how new name is *compared* with names of existing tables:

"stored as given but compared in lowercase"