Bug #16531 ENUM data type bug
Submitted: 16 Jan 2006 10:50 Modified: 16 Jan 2006 11:20
Reporter: gurudutt Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server Severity:S3 (Non-critical)
Version: OS:FreeBSD (Free BSD)
Assigned to: CPU Architecture:Any

[16 Jan 2006 10:50] gurudutt
When ENUM datatype is used for any colum of a table and a value other than what is declared along with ENUM is inserted MYSQL does not thro an error and instead inserts an empty string.

How to repeat:
Create any table having ENUM as the data type for any one column. Try to insert a value that u have not given with ENUM using a simple insert query and check what was inserted.

For example a table "data" has a column "names" having data type as enum("jill","mary","steve")

When you try to insert any other values than what is declared an error should be thrown. 
For example i try to insert "joe" which is not one among "jill", "mary" or "steve".
But no error is reported and instead and empty srting is inserted.
[16 Jan 2006 11:20] 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://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

Please, read the manual carefully (http://dev.mysql.com/doc/refman/5.0/en/enum.html):

"An ENUM is a string object with a value chosen from a list of allowed values that are enumerated explicitly in the column specification at table creation time.

The value may also be the empty string ('') or NULL under certain circumstances:

-  If you insert an invalid value into an ENUM (that is, a string not present in the list of allowed values), the empty string is inserted instead as a special error value. This string can be distinguished from a “normal” empty string by the fact that this string has the numerical value 0. More about this later."