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

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.