summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authordlenev@mysql.com <>2004-12-30 21:18:10 +0300
committerdlenev@mysql.com <>2004-12-30 21:18:10 +0300
commit2878395ab149838306719ba617dbe24507b21838 (patch)
treeb54b57244a10da8f91840a3a3c53989a5220db7c /sql
parentaeaeb3f02240af14c1c3f6d095387c1b38e2dc5f (diff)
downloadmariadb-git-2878395ab149838306719ba617dbe24507b21838.tar.gz
Fix for bug #7515 "from_unixtime(0) now returns NULL instead of
the Epoch". (With after review fixes).
Diffstat (limited to 'sql')
-rw-r--r--sql/item_timefunc.cc10
-rw-r--r--sql/item_timefunc.h3
2 files changed, 7 insertions, 6 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);
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index e04e24627d9..8ee2f935a80 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -359,8 +359,7 @@ class Item_func_from_unixtime :public Item_date_func
longlong val_int();
String *val_str(String *str);
const char *func_name() const { return "from_unixtime"; }
- void fix_length_and_dec() { decimals=0; max_length=19; }
-// enum Item_result result_type () const { return STRING_RESULT; }
+ void fix_length_and_dec() { decimals=0; max_length=19; maybe_null= 1; }
bool get_date(TIME *res,bool fuzzy_date);
};