diff options
author | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2010-02-17 16:13:42 +0400 |
---|---|---|
committer | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2010-02-17 16:13:42 +0400 |
commit | 4b260b668d66cfd6f7e8c2612461c66d2914219d (patch) | |
tree | bdbc73dd4f1984bcdae9fc74b5711cd70d3f2b34 /storage/csv | |
parent | 6cb7abe667533084e09f3df6951591332138ae0e (diff) | |
download | mariadb-git-4b260b668d66cfd6f7e8c2612461c66d2914219d.tar.gz |
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 for enum type.
mysql-test/r/csv.result:
test result
mysql-test/r/default.result:
result fix
mysql-test/t/csv.test:
test case
sql/item.cc:
Changes:
do not print warning for 'enum' type if there is no default value.
set default value.
storage/csv/ha_tina.cc:
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.
Diffstat (limited to 'storage/csv')
-rw-r--r-- | storage/csv/ha_tina.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index ca9d5215310..e3bc7f55dd2 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -679,9 +679,21 @@ int ha_tina::find_current_row(uchar *buf) if (read_all || bitmap_is_set(table->read_set, (*field)->field_index)) { + bool is_enum= ((*field)->real_type() == MYSQL_TYPE_ENUM); + /* + Here CHECK_FIELD_WARN checks that all values in the csv file are valid + which is normally the case, if they were written by + INSERT -> ha_tina::write_row. '0' values on ENUM fields are considered + invalid by Field_enum::store() but it can store them on INSERT anyway. + Thus, for enums we silence the warning, as it doesn't really mean + an invalid value. + */ if ((*field)->store(buffer.ptr(), buffer.length(), buffer.charset(), - CHECK_FIELD_WARN)) - goto err; + is_enum ? CHECK_FIELD_IGNORE : CHECK_FIELD_WARN)) + { + if (!is_enum) + goto err; + } if ((*field)->flags & BLOB_FLAG) { Field_blob *blob= *(Field_blob**) field; |