diff options
-rw-r--r-- | mysql-test/r/type_date.result | 5 | ||||
-rw-r--r-- | mysql-test/t/type_date.test | 8 | ||||
-rw-r--r-- | sql/field.cc | 7 |
3 files changed, 17 insertions, 3 deletions
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index 7a71da1bd09..846225be141 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -283,3 +283,8 @@ the_date the_time the_date the_time DROP TABLE t1; DROP VIEW v1; End of 5.1 tests +create table t1 (f1 date, key (f1)); +insert t1 values ('2010-10-10 15:foobar'); +Warnings: +Warning 1265 Data truncated for column 'f1' at row 1 +drop table t1; diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 899f912a5a5..a2639e81aa9 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -267,3 +267,11 @@ DROP TABLE t1; DROP VIEW v1; --echo End of 5.1 tests + +# +# lp:737496 Field_temporal::store_TIME_with_warning() in 5.1-micro +# +create table t1 (f1 date, key (f1)); +insert t1 values ('2010-10-10 15:foobar'); +drop table t1; + diff --git a/sql/field.cc b/sql/field.cc index 4ff9f83f5cc..f7675b82a99 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5189,15 +5189,16 @@ int Field_temporal::store_TIME_with_warning(MYSQL_TIME *ltime, was_cut= MYSQL_TIME_WARN_TRUNCATED; ret= 1; } - else if (temporal_type() == MYSQL_TIMESTAMP_DATE && + else if (!(was_cut & MYSQL_TIME_WARN_TRUNCATED) && + temporal_type() == MYSQL_TIMESTAMP_DATE && (ltime->hour || ltime->minute || ltime->second || ltime->second_part)) { - DBUG_ASSERT((was_cut & MYSQL_TIME_WARN_TRUNCATED) == 0); trunc_level= MYSQL_ERROR::WARN_LEVEL_NOTE; was_cut|= MYSQL_TIME_WARN_TRUNCATED; ret= 3; } - else if (temporal_type() == MYSQL_TIMESTAMP_TIME && + else if (!(was_cut & MYSQL_TIME_WARN_TRUNCATED) && + temporal_type() == MYSQL_TIMESTAMP_TIME && (ltime->year || ltime->month)) { ltime->year= ltime->month= ltime->day= 0; |