| Bug #29664 | Enum with commas inside strings doesn't work | ||
|---|---|---|---|
| Submitted: | 9 Jul 2007 22:02 | Modified: | 10 Jul 2007 3:41 |
| Reporter: | Niko Viitala | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | MySQL Server: General | Severity: | S3 (Non-critical) |
| Version: | 5.0.32 | OS: | Linux (Debian 4.0 GNU&Linux mysql Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (i486) using readline 5.2) |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | comma, enum | ||
[10 Jul 2007 0:32]
MySQL Verification Team
Thank you for the bug report. I was not able to repeat with source server:
[miguel@light 5.0]$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.46-debug Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> CREATE TABLE foo ( bar ENUM('string, with comma', 'escaped string\, with comma')
-> );
Query OK, 0 rows affected (0.25 sec)
mysql> DESCRIBE foo;
+-------+---------------------------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------------------------------------------------+------+-----+---------+-------+
| bar | enum('string, with comma','escaped string, with comma') | YES | | NULL | |
+-------+---------------------------------------------------------+------+-----+---------+-------+
1 row in set (0.05 sec)
mysql> INSERT INTO foo values ('string, with comma'), ('escaped string\, with comma');
Query OK, 2 rows affected (0.05 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM foo;
+----------------------------+
| bar |
+----------------------------+
| string, with comma |
| escaped string, with comma |
+----------------------------+
2 rows in set (0.00 sec)
mysql>
[10 Jul 2007 3:41]
Niko Viitala
MySQL is from Debian packages.
[31 Jul 2007 11:50]
Sergei Kulakov
I have the same problem with MySql 4.1.22-community-nt under Windows XP
[11 Aug 2007 13:15]
[ name withheld ]
I have problems too with commas in enum columns.
$ mysql --default-character-set=utf8 -uroot test
mysql> CREATE TABLE enum_test ( enum_col enum('', 'String, with comma', 'Another, string') character set latin1 ) default character set utf8;
mysql> SHOW FULL COLUMNS FROM enum_test;
+----------+---------------------------------------------------+-----------...
| Field | Type | Collation
+----------+---------------------------------------------------+-----------...
| enum_col | enum('','Stringÿ with comma','Anotherÿ string') | latin1_swedish_ci
+----------+---------------------------------------------------+-----------...
When the enum column has utf8 character set, "describe table" prints the enum like that:
enum('string (nothings after the first comma)
mysql> ALTER TABLE enum_test CHANGE COLUMN enum_col enum_col enum('String, with comma', 'Another, string') character set utf8;
+----------+--------------+-------------...
| Field | Type | Collation
+----------+--------------+-------------...
| enum_col | enum('String | utf8_general_ci +----------+--------------+-------------...
==> The enum is truncated in describe/show columns with utf8 character set.
Seems to be fixed in 5.0.41 since I can't repeat this on 5.0.41, but I don't know if the fix is a Debian one or not. This was tested on
mysql version 5.0.32-Debian_7etch1-log.
[11 Aug 2007 13:41]
[ name withheld ]
After more research it seems this was fixed in 5.0.36: http://bugs.mysql.com/bug.php?id=24660

Description: Creating or altering table column with enum with commas inside strings replaces commas with ÿ. How to repeat: mysql> CREATE TABLE foo ( bar ENUM('string, with comma', 'escaped string\, with comma') ); Query OK, 0 rows affected (0.03 sec) mysql> DESCRIBE foo; +-------+---------------------------------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------------------------------------------------+------+-----+---------+-------+ | bar | enum('stringÿ with comma','escaped stringÿ with comma') | YES | | NULL | | +-------+---------------------------------------------------------+------+-----+---------+-------+ 1 row in set (0.00 sec) mysql> INSERT INTO foo values ('string, with comma'), ('escaped string\, with comma'); Query OK, 2 rows affected, 2 warnings (0.00 sec) Records: 2 Duplicates: 0 Warnings: 2 mysql> SHOW WARNINGS; +---------+------+------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------+ | Warning | 1265 | Data truncated for column 'bar' at row 1 | | Warning | 1265 | Data truncated for column 'bar' at row 2 | +---------+------+------------------------------------------+ 2 rows in set (0.00 sec) mysql> SELECT * FROM foo; +------+ | bar | +------+ | | | | +------+ 2 rows in set (0.00 sec)