Bug #43703 #mysql50# prefix not removed by mysqlcheck if tablename contains backtick
Submitted: 17 Mar 2009 14:19 Modified: 18 Feb 2015 11:09
Reporter: Vemund Østgaard Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.33 OS:Any
Assigned to: CPU Architecture:Any

[17 Mar 2009 14:19] Vemund Østgaard
Description:
The problem is observed in a test of upgrade from 5.0.72 to 5.0.33.

When running the mysql_upgrade command as part of the upgrade process, table names that have been given a #mysql50# prefix are supposed to be altered back to the original name. This fails for a table that contains a backtick in the tablename:

Running 'mysqlcheck'...
Failed to RENAME TABLE `#mysql50#t1a`b` TO `t1a`b`
Error: 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 'b` TO `t1a`b`' at line 1

I've verified that the problem was also present in 5.1.32, but it was probably overlooked during manual inspection of the result because of other noise in the test. In 5.1.30 it seems mysql_upgrade did not try to fix the table names.

How to repeat:
The test does the following:

1. Start server, version 5.0.72
2. Create a table named t1a`b
(t1a<backtick>b)
3. Restart server, version 5.1.33
4. Run mysql_upgrade
5. Observe output from mysqlcheck contains message "Failed to RENAME TABLE" and verify table name still contains #mysql50# prefix.
[21 Apr 2010 14:23] Hadrien Huvelle
Hi,

I had the same problem. But only for the table containing '-' in the name.

for example: Table "ABCD" is correctly imported. But Table "AB-CB" not!

perhaps mysqlcheck doesn't use table name in quote ``

Kind regards

Hadrien Huvelle
Baboum.be
[17 Oct 2010 9:15] Teodor Milkov
Looks like the same problem is present for ~ (tilde) symbol.

Failed to RENAME TABLE `#mysql50#Locations~` TO `Locations~`
Error: Can't find file: './db_res/.frm' (errno: 2)

This is InnoDB.
[18 Feb 2015 11:09] Jon Olav Hauglid
"Conversion of pre-MySQL 5.1 database names containing special characters to 5.1 format with the addition of a #mysql50# prefix is deprecated as of MySQL 5.7.6 and will be removed in a future version of MySQL. Because such conversions are deprecated, the --fix-db-names and --fix-table-names options for mysqlcheck and the UPGRADE DATA DIRECTORY NAME clause for the ALTER DATABASE statement are also deprecated."

http://dev.mysql.com/doc/refman/5.7/en/identifier-mapping.html