summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-03-18 19:45:00 +0100
committerSergei Golubchik <sergii@pisem.net>2011-03-18 19:45:00 +0100
commite79a72a410ef74e5105616da8eceb2798f485c57 (patch)
treeff44f5b580a5383e042e8c28780f290b87cf7070
parentc629477981cc491a12c3664b81f9fb33db00e481 (diff)
downloadmariadb-git-e79a72a410ef74e5105616da8eceb2798f485c57.tar.gz
lp:737496 Assertion `(was_cut & 1) == 0' failed in Field_temporal::store_TIME_with_warning() in 5.1-micro
fix incorrect assert
-rw-r--r--mysql-test/r/type_date.result5
-rw-r--r--mysql-test/t/type_date.test8
-rw-r--r--sql/field.cc7
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;