Bug #26145 SET type stores '' without warning
Submitted: 7 Feb 2007 12:22 Modified: 7 Feb 2007 13:00
Reporter: Yoshinori Matsunobu Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version: OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[7 Feb 2007 12:22] Yoshinori Matsunobu
Description:

How to repeat:
mysql> SET SQL_MODE="";
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t1(c1 SET('a','b') NULL) ENGINE=myisam;
Query OK, 0 rows affected (0.03 sec)

mysql> INSERT INTO t1 VALUES('');
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM t1;
+------+
| c1   |
+------+
|      |
+------+
1 row in set (0.00 sec)

mysql> SET SQL_MODE="TRADITIONAL";

mysql> CREATE TABLE t1(c1 SET('a','b') NULL) ENGINE=myisam;
Query OK, 0 rows affected (0.02 sec)

mysql> INSERT INTO t1 VALUES('');
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO t1 VALUES('123');
ERROR 1265 (01000): Data truncated for column 'c1' at row 1

Warning w/ ENUM.
mysql> SET SQL_MODE="";
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t1(c1 ENUM('a','b') NULL) ENGINE=myisam;
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO t1 VALUES('');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+---------+------+-----------------------------------------+
| Level   | Code | Message                                 |
+---------+------+-----------------------------------------+
| Warning | 1265 | Data truncated for column 'c1' at row 1 |
+---------+------+-----------------------------------------+
1 row in set (0.00 sec)

Suggested fix:
Should be handled like ENUM.
[7 Feb 2007 13:00] Valeriy Kravchuk
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at:

http://dev.mysql.com/doc/refman/5.0/en/set.html

and

http://dev.mysql.com/doc/refman/5.0/en/enum.html