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"
Regards / Mit vielen Grüßen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Engineer/Server Architect
/_/ /_/\_, /___/\___\_\___/ Sun Microsystems GmbH, HRB München 161028
<___/ Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Häring