Hi Peter!
Could you comment this ENUM field vagueness(see below)?
Sergei Golubchik wrote:
> Hi, Sergey!
>
> On Feb 27, Sergey Glukhov wrote:
>> #At file:///home/gluh/MySQL/mysql-5.1-bug-33717/ based on
> revid:kgeorge@stripped
>>
>> 2828 Sergey Glukhov 2009-02-27
>> Bug#33717 INSERT...(default) fails for enum. Crashes CSV tables, loads
> spaces for MyISAM
>> Table corruption happens during table reading in
> ha_tina::find_current_row() func.
>> Field::store() method returns error(true) if stored value is 0.
>> The fix:
>> added special case for enum type which correctly processes 0 value.
>> Additional fix:
>> INSERT...(default) and INSERT...() have the same behaviour now.
>>
>> === modified file 'mysql-test/r/csv.result'
>> --- a/mysql-test/r/csv.result 2009-01-23 12:22:05 +0000
>> +++ b/mysql-test/r/csv.result 2009-02-27 10:42:53 +0000
>> @@ -5394,17 +5394,28 @@ select * from t1;
>> ERROR HY000: File 'MYSQLD_DATADIR/test/t1.CSV' not found (Errcode: 2)
>> unlock tables;
>> drop table t1;
>> +CREATE TABLE t1 (e enum('foo','bar') NOT NULL) ENGINE = CSV;
>> +INSERT INTO t1 VALUES();
>> Warnings:
>> +Warning 1364 Field 'e' doesn't have a default value
>> +INSERT INTO t1 VALUES(default);
>> +Warnings:
>> +Warning 1364 Field 'e' doesn't have a default value
>> +INSERT INTO t1 VALUES(0);
>> +Warnings:
>> +Warning 1265 Data truncated for column 'e' at row 1
>> +INSERT INTO t1 VALUES(3);
>> +Warnings:
>> +Warning 1265 Data truncated for column 'e' at row 1
>> +INSERT INTO t1 VALUES(-1);
>> +Warnings:
>> +Warning 1265 Data truncated for column 'e' at row 1
>> +SELECT * FROM t1;
>> +e
>> +foo
>> +foo
>> +
>> +
>> +
>> +DROP TABLE t1;
>> End of 5.1 tests
>
> I'm not sure we can do that :(
> Although I agree that this makes ENUM to be more consistent with other
> field types, the manual says explicitly:
>
> * If an *Note `ENUM': enum. column is declared to allow `NULL', the
> `NULL' value is a legal value for the column, and the default
> value is `NULL'. If an *Note `ENUM': enum. column is declared `NOT
> NULL', its default value is the first element of the list of
> allowed values.
>
> I think that means that there's always a default value, it cannot say
> "Field .... doesn't have a default value"
>
Existing behaviour(5.1) is following:
----
+CREATE TABLE t1 (e enum('foo','bar') NOT NULL);
+INSERT INTO t1 VALUES(default);
+Warnings:
+Warning 1364 Field 'e' doesn't have a default value
----
This behaviour contradicts the manual which says that
ENUM type always have default value(see Serg's comment).
There are ways to fix it:
1. Remove "Field .... doesn't have a default value" warning(going to be
fixed in 6.0)
2. Add some info to manual that if default value is not provided
explicitly then
a warning is issued.
Which way would you recommend? or maybe you have another idea about this?
Regards,
Gluh