summaryrefslogtreecommitdiff
path: root/sql/set_var.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r--sql/set_var.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 2b7ee04649d..1df81776a51 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -2900,14 +2900,20 @@ int set_var_collation_client::update(THD *thd)
bool sys_var_timestamp::check(THD *thd, set_var *var)
{
- double val= var->value->val_real();
- if (val < 0 || val > MY_TIME_T_MAX)
+ ulonglong sec;
+ ulong sec_part;
+ char buf[64], *errval= 0;
+ if (var->value->get_seconds(&sec, &sec_part))
+ errval= llstr(sec, buf);
+ else if (sec > TIMESTAMP_MAX_VALUE)
+ errval= ullstr(sec, buf);
+
+ if (errval)
{
- char buf[64];
- my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "timestamp", llstr((longlong)val, buf));
+ my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), "timestamp", errval);
return TRUE;
}
- var->save_result.ulonglong_value= hrtime_from_time(val);
+ var->save_result.ulonglong_value= hrtime_from_time(sec)+sec_part;
return FALSE;
}