Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-05-08 00:52:12+04:00, evgen@stripped +3 -0
Bug#27670: LOAD DATA does not set TIMESTAMP default value when there is not
enough data.
The LOAD DATA sets the current time in the TIMESTAMP field with
CURRENT_TIMESTAMP default value when the field is detected to be 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/r/loaddata.result@stripped, 2007-05-08 00:51:24+04:00, evgen@stripped +19
-0
Added a test case for the bug#27670: LOAD DATA does not set TIMESTAMP default value
when there is not
enough data.
mysql-test/t/loaddata.test@stripped, 2007-05-08 00:50:54+04:00, evgen@stripped +26 -0
Added a test case for the bug#27670: LOAD DATA does not set TIMESTAMP default value
when there is not
enough data.
sql/sql_load.cc@stripped, 2007-05-08 00:51:34+04:00, evgen@stripped +4 -0
Bug#27670: LOAD DATA does not set TIMESTAMP default value when there is not
enough data.
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.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /mnt/gentoo64/work/27670-bug-5.0-opt-mysql
--- 1.112/sql/sql_load.cc 2007-04-12 13:49:59.000000000 +0400
+++ 1.113/sql/sql_load.cc 2007-05-08 00:51:34.000000000 +0400
@@ -585,6 +585,8 @@
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 @@
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
--- 1.27/mysql-test/r/loaddata.result 2007-04-07 00:10:58.000000000 +0400
+++ 1.28/mysql-test/r/loaddata.result 2007-05-08 00:51:24.000000000 +0400
@@ -165,3 +165,22 @@
2
SET @@SQL_MODE=@OLD_SQL_MODE;
drop table t1,t2;
+create table t1(f1 int, f2 timestamp not null default current_timestamp);
+create table t2(f1 int);
+insert into t2 values(1),(2);
+Warnings:
+Warning 1261 Row 1 doesn't contain data for all columns
+Warning 1261 Row 2 doesn't contain data for all columns
+select f1 from t1 where f2 <> '0000-00-00 00:00:00';
+f1
+1
+2
+delete from t1;
+Warnings:
+Warning 1261 Row 1 doesn't contain data for all columns
+Warning 1261 Row 2 doesn't contain data for all columns
+select f1 from t1 where f2 <> '0000-00-00 00:00:00';
+f1
+1
+2
+drop table t1,t2;
--- 1.21/mysql-test/t/loaddata.test 2007-04-07 00:10:56.000000000 +0400
+++ 1.22/mysql-test/t/loaddata.test 2007-05-08 00:50:54.000000000 +0400
@@ -152,4 +152,30 @@
--exec rm $MYSQLTEST_VARDIR/tmp/t1
SET @@SQL_MODE=@OLD_SQL_MODE;
drop table t1,t2;
+
+#
+# Bug#27670: LOAD DATA does not set TIMESTAMP default value when there is not
+# enough data.
+#
+create table t1(f1 int, f2 timestamp not null default current_timestamp);
+create table t2(f1 int);
+insert into t2 values(1),(2);
+disable_query_log;
+eval select * into outfile '$MYSQLTEST_VARDIR/tmp/t2' from t2;
+eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1;
+enable_query_log;
+select f1 from t1 where f2 <> '0000-00-00 00:00:00';
+--exec rm $MYSQLTEST_VARDIR/tmp/t2
+delete from t1;
+disable_query_log;
+eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t2'
+FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'
+FROM t2;
+eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1
+FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n';
+enable_query_log;
+select f1 from t1 where f2 <> '0000-00-00 00:00:00';
+--exec rm $MYSQLTEST_VARDIR/tmp/t2
+drop table t1,t2;
+
# End of 5.0 tests
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.2475) BUG#27670 | eugene | 7 May |