summaryrefslogtreecommitdiff
path: root/mysql-test/t/type_date.test
diff options
context:
space:
mode:
authorEvgeny Potemkin <epotemkin@mysql.com>2010-11-04 16:18:27 +0300
committerEvgeny Potemkin <epotemkin@mysql.com>2010-11-04 16:18:27 +0300
commit368ac9f03ef9c1f0c9d02985c13708ac52cfbfaf (patch)
treeb06df733326a27bfe4c649b142323518161c1d3c /mysql-test/t/type_date.test
parentb431da62147ed8d1ed5433c810a92ed6eadcbf27 (diff)
downloadmariadb-git-368ac9f03ef9c1f0c9d02985c13708ac52cfbfaf.tar.gz
Bug#57278: Crash on min/max + with date out of range.
MySQL officially supports DATE values starting from 1000-01-01. This is enforced for int values, but not for string values, thus one could easily insert '0001-01-01' value. Int values are checked by number_to_datetime function and Item_cache_datetime::val_str uses it to fill MYSQL_TIME struct out of cached int value. This leads to the scenario where Item_cache_datetime caches a non-null datetime value and when it tries to convert it from int to string number_to_datetime function treats the value as out-of-range and returns an error and Item_cache_datetime::val_str returns NULL for a non-null value. Due to this inconsistency server crashes. Now number_to_datetime allows DATE values below 1000-01-01 if the TIME_FUZZY_DATE flag is set. Better NULL handling for Item_cache_datetime. Added the Item_cache_datetime::store function to reset str_value_cached flag when an item is stored. mysql-test/r/type_date.result: Added a test case for the bug#57278. mysql-test/t/type_date.test: Added a test case for the bug#57278. sql-common/my_time.c: Bug#57278: Crash on min/max + with date out of range. Now number_to_datetime allows DATE values below 1000-01-01 if the TIME_FUZZY_DATE flag is set. sql/item.cc: Bug#57278: Crash on min/max + with date out of range. Item_cache_datetime::val_str now better handles null_value.
Diffstat (limited to 'mysql-test/t/type_date.test')
-rw-r--r--mysql-test/t/type_date.test8
1 files changed, 8 insertions, 0 deletions
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 11f2b68804a..6dec86dacab 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -284,4 +284,12 @@ DROP TABLE t1;
--echo #
+--echo #
+--echo # Bug#57278: Crash on min/max + with date out of range.
+--echo #
+set @a=(select min(makedate('111','1'))) ;
+select @a;
+--echo #
+
+
--echo End of 6.0 tests