summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc57
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();