Bug #20386 Legal identifier rejected as table name
Submitted: 12 Jun 2006 4:20 Modified: 13 Jun 2006 14:11
Reporter: Mark V Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.19-nt OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[12 Jun 2006 4:20] Mark V
Description:
Thanks to the devlopers and contributors for a very useful product.   I hope this contributes a little?

I believe MySQL is rejecting a legal table name.
Note that 
http://dev.mysql.com/doc/refman/5.0/en/legal-names.html
suggests:

"It is recommended that you do not use names of the form Me or MeN, where M and N are integers. For example, avoid using 1e or 2e2 as identifiers, because an expression such as 1e+3  is ambiguous. Depending on context, it might be interpreted as the expression 1e + 3 or as the number 1e+3."

However it seams that even when it is not ambiguous MySQL rejects an otherwise legal identifier (at least for a table name).

How to repeat:
CREATE TABLE `test`.`6706e2_suff` (
  `col1` int);
	INSERT INTO `test`.`6706e2_suff` VALUES (1);
	INSERT INTO `test`.`6706e2_suff` VALUES (2);
	INSERT INTO `test`.`6706e2_suff` VALUES (3);

	CREATE TABLE `test`.`pre_6706e2_suff` (
  `col1` int);
	INSERT INTO `test`.`pre_6706e2_suff` VALUES (1);
	INSERT INTO `test`.`pre_6706e2_suff` VALUES (2);
	INSERT INTO `test`.`pre_6706e2_suff` VALUES (3);

CREATE TABLE `test`.`000021_suff` (
  `col1` int);
	INSERT INTO `test`.`000021_suff` VALUES (1);
	INSERT INTO `test`.`000021_suff` VALUES (2);
	INSERT INTO `test`.`000021_suff` VALUES (3);
USE `test`;

SELECT * FROM 000021_suff;
SELECT * FROM 6706e2_suff;
SELECT * FROM pre_6706e2_suff;

DESCRIBE `000021_suff`;
DESCRIBE `6706e2_suff`;

DESCRIBE 000021_suff;
DESCRIBE 6706e2_suff;
DESCRIBE pre_6706e2_suff;

Suggested fix:
One has to quote any identifier "of the form Me or MeN, where M and N are integers" where the leading trailing part of an identifier could be interpreted as an "ambiguous number/expression"?

This is close to requiring that identifiers always be quoted using `` - regardless of whether it may or maynot be ambiguous.  Since it caused me no end of trouble it might be worth emphasising this in the naming documentation.
Hope this helps.
[12 Jun 2006 4:27] Mark V
I removed the 'by DESCRIBE' qualification from the bug description, since this error also occurs with SELECT.
[13 Jun 2006 14:11] Sveta Smirnova
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

'6706e2_suff' is ambiguous. Try SELECT 6706e2_suff; to see it.