Bug #18396 Identifiers: Byte with value 255 not allowed
Submitted: 21 Mar 2006 15:09 Modified: 22 Jun 2006 15:26
Reporter: Paul DuBois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1 OS:
Assigned to: Alexander Barkov CPU Architecture:Any

[21 Mar 2006 15:09] Paul DuBois
Description:
As of MySQL 5.1.6, database and table identifiers are encoded
when creating the associated directory and filenames, so as
to allow formerly unusable characters in identifiers.

However, it is still not possible to use a byte with value 255 in
identifiers.

How to repeat:
Example Perl DBI script:

#!/usr/bin/perl -w

use DBI;

my $name = "abc\xFFdef";
print "name: $name\n";
my $stmt = "CREATE TABLE `$name` (i INT)";
print "stmt: $stmt\n";

my $dbh = DBI->connect ("DBI:mysql:test:localhost", "testuser", "testpass");
$dbh->do ($stmt);
$dbh->disconnect ();

The script fails with this message:

DBD::mysql::db do failed: 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 '?def` (i INT)' at line 1 at ./name-test.pl line 11.

If I change \xFF to \xFE, the script succeeds.

This is not a matter of the 255-byte being lost on the way to the server.
A hex dump of the query log shows this, with the "ff" intact:

0dda0: 35 32 38 20 51 75 69 74  09 0a 30 36 30 33 32 31  528 Quit..060321
0ddb0: 20 20 39 3a 30 37 3a 30  34 20 20 35 32 39 20 43    9:07:04  529 C
0ddc0: 6f 6e 6e 65 63 74 09 74  65 73 74 75 73 65 72 40  onnect.testuser@
0ddd0: 6c 6f 63 61 6c 68 6f 73  74 20 6f 6e 20 74 65 73  localhost on tes
0dde0: 74 0a 09 09 20 20 35 32  39 20 51 75 65 72 79 09  t...  529 Query.
0ddf0: 73 65 74 20 61 75 74 6f  63 6f 6d 6d 69 74 3d 31  set autocommit=1
0de00: 0a 09 09 20 20 35 32 39  20 51 75 65 72 79 09 43  ...  529 Query.C
0de10: 52 45 41 54 45 20 54 41  42 4c 45 20 60 61 62 63  REATE TABLE `abc
0de20: ff 64 65 66 60 20 28 69  20 49 4e 54 29 0a 09 09  .def` (i INT)...
0de30: 20 20 35 32 39 20 51 75  69 74 09 0a               529 Quit..
[22 Mar 2006 13:48] MySQL Verification Team
Thank you for the bug report.

stmt: CREATE TABLE `abc def` (i INT)
DBD::mysql::db do failed: 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 ' def` (i INT)' at line 1 at test.pl line 11.
[6 Jun 2006 17:17] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/7329
[22 Jun 2006 15:24] Paul DuBois
Noted in 5.1.12 changelog.

Identifiers could not contain bytes with a value of 255, though 
that should be allowed as of the identifier-encoding changes made
in MySQL 5.1.6.