From 25e32d83d6d5fdce25ba4ef68885ffbf9f7a934f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Jan 2006 14:42:46 +0100 Subject: [PATCH] fix for bug#15828 problem was not checking 2nd parameter of str_to_date against NULL mysql-test/r/date_formats.result: bk commit --- mysql-test/r/date_formats.result | 6 ++++++ mysql-test/t/date_formats.test | 7 +++++++ sql/item_timefunc.cc | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 34a2dedd976..b2dc1f7a67b 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -464,3 +464,9 @@ d1 d2 02 February 01 January drop table t1; +select str_to_date( 1, NULL ); +str_to_date( 1, NULL ) +NULL +select str_to_date( NULL, 1 ); +str_to_date( NULL, 1 ) +NULL diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 6d501865d2c..dd31f1509c0 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -268,4 +268,11 @@ insert into t1 (f1) values ("2005-01-01"); insert into t1 (f1) values ("2005-02-01"); select date_format(f1, "%m") as d1, date_format(f1, "%M") as d2 from t1 order by date_format(f1, "%M"); drop table t1; + +# +# Bug #15828 +# +select str_to_date( 1, NULL ); +select str_to_date( NULL, 1 ); + # End of 4.1 tests diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index eb58b180ed7..d060612c9f6 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2750,7 +2750,7 @@ void Item_func_str_to_date::fix_length_and_dec() cached_field_type= MYSQL_TYPE_STRING; max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; cached_timestamp_type= MYSQL_TIMESTAMP_NONE; - if ((const_item= args[1]->const_item())) + if ((const_item= args[1]->const_item()) && !args[1]->null_value) { format= args[1]->val_str(&format_str); cached_format_type= get_date_time_result_type(format->ptr(),