Bug #42323 | Documentation states identifiers can't have ASCII NULL incorrectly | ||
---|---|---|---|
Submitted: | 24 Jan 2009 17:08 | Modified: | 2 Mar 2009 18:48 |
Reporter: | Sheeri Cabral (Candidate Quality Contributor) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | 6.0, probably 5.1 as well | OS: | Any |
Assigned to: | Paul DuBois | CPU Architecture: | Any |
Tags: | identifiers |
[24 Jan 2009 17:08]
Sheeri Cabral
[25 Jan 2009 16:20]
Sveta Smirnova
Thank you for the report. But you create table/field/database not ASCII NULL character, but with string "0x00" which is allowed in identifiers names. Please try example with real NULL: $php -r 'echo "create table `test\0` (f1 int)";' create table `test` (f1 int) $php -r 'echo "create table `test\0` (f1 int)";' | mysql test ERROR 1113 (42000) at line 1: A table must have at least 1 column $php -r 'echo "create table `test` (`f1\0` int)";' | mysql test ERROR 1064 (42000) at line 1: 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 '' at line 1 $php -r 'echo "create database `foo\0bar`";' | mysql test $mysql -e "show databases like 'foo%';" +-----------------+ | Database (foo%) | +-----------------+ | foo | +-----------------+ So it really does not contain null, although not reject statements which contain such values with proper message.
[25 Jan 2009 16:25]
Sveta Smirnova
Further investigation showed this is mysql command line client problem as a program which uses C API returns correct error message: $php -r 'mysql_connect("127.0.0.1:3306", "root", ""); mysql_query("create database `foo\0bar`"); var_dump(mysql_error());' string(146) "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 '' at line 1" $php -r 'mysql_connect("127.0.0.1:3306", "root", ""); mysql_select_db("test"); mysql_query("create table `test\0` (f1 int)"); var_dump(mysql_error());' string(146) "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 '' at line 1" $php -r 'mysql_connect("127.0.0.1:3306", "root", ""); mysql_select_db("test"); mysql_query("create table `test` (`f1\0` int)"); var_dump(mysql_error());' string(146) "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 '' at line 1"
[25 Jan 2009 16:32]
Sheeri Cabral
I copied from the manual page. "No identifier can contain ASCII 0 (0x00) or a byte with a value of 255. " So I used 0x00. The page itself is wrong anyway because it's stating that ASCII 0 is 0x00 (hex 0!)
[2 Mar 2009 18:44]
Paul DuBois
As of 5.1, any character is legal except ASCII NUL (0x00). I'll remove "255" from the description in 5.1 and up. Also, I'll clarify that \0 is ASCII NUL, not ASCII 0, in all versions.
[2 Mar 2009 18:48]
Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.