summaryrefslogtreecommitdiff
path: root/sql/sql_load.cc
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-05-09 00:23:16 +0400
committerunknown <evgen@moonbone.local>2007-05-09 00:23:16 +0400
commit80788a3462c18d5c603ee4badb2c51e7f87205ae (patch)
tree69ab7b065ce4093f1b8cd0efe745fc437fc35bdf /sql/sql_load.cc
parentcc33cf29834abff0e07dac5f9c0e083c37722267 (diff)
downloadmariadb-git-80788a3462c18d5c603ee4badb2c51e7f87205ae.tar.gz
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. mysql-test/t/loaddata.test: Added a test case for the bug#27670: LOAD DATA does not set CURRENT_TIMESTAMP default value for a TIMESTAMP field when no value has been provided. mysql-test/r/loaddata.result: Added a test case for the bug#27670: LOAD DATA does not set CURRENT_TIMESTAMP default value for a TIMESTAMP field when no value has been provided. sql/sql_load.cc: Bug#27670: LOAD DATA does not set CURRENT_TIMESTAMP default value for a TIMESTAMP field when no value has been provided. 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.
Diffstat (limited to 'sql/sql_load.cc')
-rw-r--r--sql/sql_load.cc4
1 files changed, 4 insertions, 0 deletions
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