diff options
author | Alexander Barkov <bar@mariadb.org> | 2018-03-07 19:52:00 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-02-23 17:43:59 +0400 |
commit | 8036ad541e9da4073a6136052e41c22c758b770e (patch) | |
tree | da5b808faf07b27226e2dcd40927a75923c9693e /sql/field.cc | |
parent | 0ef8848526c117ed8731e42edbb3f28652b168f2 (diff) | |
download | mariadb-git-8036ad541e9da4073a6136052e41c22c758b770e.tar.gz |
Backporting MDEV-15497 Wrong empty value in a GEOMETRY column on LOAD DATA
This is a part of "MDEV-18045 Backporting the MDEV-15497 changes to 10.2 branch"
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/sql/field.cc b/sql/field.cc index cfd51da1487..18f99945645 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1361,6 +1361,26 @@ warn: } +/** + If a field does not have a corresponding data, it's behavior can vary: + - In case of the fixed file format + it's set to the default value for the data type, + such as 0 for numbers or '' for strings. + - In case of a non-fixed format + it's set to NULL for nullable fields, and + it's set to the default value for the data type for NOT NULL fields. + This seems to be by design. +*/ +bool Field::load_data_set_no_data(THD *thd, bool fixed_format) +{ + reset(); // Do not use the DEFAULT value + if (fixed_format) + set_notnull(); + set_has_explicit_value(); // Do not auto-update this field + return false; +} + + bool Field::load_data_set_null(THD *thd) { reset(); @@ -1375,6 +1395,21 @@ bool Field::load_data_set_null(THD *thd) } +void Field::load_data_set_value(const char *pos, uint length, + CHARSET_INFO *cs) +{ + /* + Mark field as not null, we should do this for each row because of + restore_record... + */ + set_notnull(); + if (this == table->next_number_field) + table->auto_increment_field_not_null= true; + store(pos, length, cs); + set_has_explicit_value(); // Do not auto-update this field +} + + /** Numeric fields base class constructor. */ @@ -5363,6 +5398,22 @@ int Field_timestamp::set_time() } +bool Field_timestamp::load_data_set_no_data(THD *thd, bool fixed_format) +{ + if (!maybe_null()) + { + /* + Timestamp fields that are NOT NULL are autoupdated if there is no + corresponding value in the data file. + */ + set_time(); + set_has_explicit_value(); + return false; + } + return Field::load_data_set_no_data(thd, fixed_format); +} + + bool Field_timestamp::load_data_set_null(THD *thd) { if (!maybe_null()) @@ -8735,6 +8786,12 @@ bool Field_geom::can_optimize_range(const Item_bool_func *cond, } +bool Field_geom::load_data_set_no_data(THD *thd, bool fixed_format) +{ + return Field_geom::load_data_set_null(thd); +} + + bool Field_geom::load_data_set_null(THD *thd) { Field_blob::reset(); |