summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authorunknown <dlenev@mysql.com>2004-12-30 21:18:10 +0300
committerunknown <dlenev@mysql.com>2004-12-30 21:18:10 +0300
commit1ffd688a4a341157df30602a7f3c6d97f9a4e010 (patch)
treeb54b57244a10da8f91840a3a3c53989a5220db7c /sql/item_timefunc.cc
parent2fb340b5209dda8f71f372fed17d65a0c5814821 (diff)
downloadmariadb-git-1ffd688a4a341157df30602a7f3c6d97f9a4e010.tar.gz
Fix for bug #7515 "from_unixtime(0) now returns NULL instead of
the Epoch". (With after review fixes). mysql-test/r/func_time.result: Added test for bug #7515 "from_unixtime(0) now returns NULL instead of the Epoch". mysql-test/t/func_time.test: Added test for bug #7515 "from_unixtime(0) now returns NULL instead of the Epoch". sql/item_timefunc.cc: Item_func_from_unixtime: from_unixtime(0) should return Epoch instead of NULL. sql/item_timefunc.h: Item_func_from_unixtime: - Removed unused method definition. - fix_length_and_dec() should set maybe_null to true since now from_unixtime() can return NULL even in case when none of its arguments is NULL.
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index d188310be24..b03fd151383 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -946,10 +946,12 @@ bool Item_func_from_unixtime::get_date(TIME *ltime,
{
struct tm tm_tmp;
time_t tmp;
- longlong arg= args[0]->val_int();
- if ((null_value= (args[0]->null_value ||
- arg < TIMESTAMP_MIN_VALUE ||
- arg > TIMESTAMP_MAX_VALUE)))
+ ulonglong arg= (ulonglong)(args[0]->val_int());
+ /*
+ "arg > TIMESTAMP_MAX_VALUE" check also covers case of negative
+ from_unixtime() argument since arg is unsigned.
+ */
+ if ((null_value= (args[0]->null_value || arg > TIMESTAMP_MAX_VALUE)))
return 1;
tmp= arg;
localtime_r(&tmp,&tm_tmp);