Commit 79997ff7 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/dlenev/src/mysql-4.1-bg6439

parents 4285cd99 7c0504ad
......@@ -474,6 +474,12 @@ unix_timestamp(@a)
select unix_timestamp('1969-12-01 19:00:01');
unix_timestamp('1969-12-01 19:00:01')
0
select from_unixtime(0);
from_unixtime(0)
NULL
select from_unixtime(2145916800);
from_unixtime(2145916800)
NULL
CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time);
INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08");
SELECT * from t1;
......
......@@ -229,6 +229,13 @@ select @a:=FROM_UNIXTIME(1);
select unix_timestamp(@a);
select unix_timestamp('1969-12-01 19:00:01');
#
# Test for bug #6439 "unix_timestamp() function returns wrong datetime
# values for too big argument". It should return error instead.
#
select from_unixtime(0);
select from_unixtime(2145916800);
#
# Test types from + INTERVAL
#
......
......@@ -1601,50 +1601,46 @@ void Item_func_from_unixtime::fix_length_and_dec()
String *Item_func_from_unixtime::val_str(String *str)
{
TIME time_tmp;
my_time_t tmp;
DBUG_ASSERT(fixed == 1);
tmp= (time_t) args[0]->val_int();
if ((null_value=args[0]->null_value))
goto null_date;
thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, tmp);
if (get_date(&time_tmp, 0))
return 0;
if (str->alloc(20*MY_CHARSET_BIN_MB_MAXLEN))
goto null_date;
{
null_value= 1;
return 0;
}
make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str);
return str;
null_date:
null_value=1;
return 0;
}
longlong Item_func_from_unixtime::val_int()
{
TIME time_tmp;
my_time_t tmp;
DBUG_ASSERT(fixed == 1);
tmp= (time_t) (ulong) args[0]->val_int();
if ((null_value=args[0]->null_value))
if (get_date(&time_tmp, 0))
return 0;
current_thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, tmp);
return (longlong) TIME_to_ulonglong_datetime(&time_tmp);
}
bool Item_func_from_unixtime::get_date(TIME *ltime,
uint fuzzy_date __attribute__((unused)))
{
my_time_t tmp=(my_time_t) args[0]->val_int();
if ((null_value=args[0]->null_value))
longlong tmp= args[0]->val_int();
if ((null_value= (args[0]->null_value ||
tmp < TIMESTAMP_MIN_VALUE ||
tmp > TIMESTAMP_MAX_VALUE)))
return 1;
current_thd->variables.time_zone->gmt_sec_to_TIME(ltime, tmp);
thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)tmp);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment