From 98fa542a087b84ff003df21314f100cc6b0dc37a Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Wed, 9 May 2007 00:23:16 +0400 Subject: Bug#27670: LOAD DATA does not set CURRENT_TIMESTAMP default value for a TIMESTAMP field when no value has been provided. The LOAD DATA sets the current time in the TIMESTAMP field with CURRENT_TIMESTAMP default value when the field is detected as a null. But when the LOAD DATA command loads data from a file that doesn't contain enough data for all fields then the rest of fields are simply set to null without any check. This leads to no value being inserted to such TIMESTAMP field. Now the read_sep_field() and the read_fixed_length() functions set current time to the TIMESTAMP field with CURRENT_TIMESTAMP default value in all cases when a NULL value is loaded to the field. --- sql/sql_load.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql/sql_load.cc') diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ee6d2d0a572..d14e165a788 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -585,6 +585,8 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_TOO_FEW_RECORDS, ER(ER_WARN_TOO_FEW_RECORDS), thd->row_count); + if (!field->maybe_null() && field->type() == FIELD_TYPE_TIMESTAMP) + ((Field_timestamp*) field)->set_time(); } else { @@ -770,6 +772,8 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, thd->row_count); DBUG_RETURN(1); } + if (!field->maybe_null() && field->type() == FIELD_TYPE_TIMESTAMP) + ((Field_timestamp*) field)->set_time(); /* QQ: We probably should not throw warning for each field. But how about intention to always have the same number -- cgit v1.2.1