Commit 4ef7ac5c authored by dlenev@mysql.com's avatar dlenev@mysql.com

Manual merge of fix for bugs of #7297 and #7515 into 4.1 tree.

parents e0280694 2600fb3b
...@@ -474,12 +474,15 @@ unix_timestamp(@a) ...@@ -474,12 +474,15 @@ unix_timestamp(@a)
select unix_timestamp('1969-12-01 19:00:01'); select unix_timestamp('1969-12-01 19:00:01');
unix_timestamp('1969-12-01 19:00:01') unix_timestamp('1969-12-01 19:00:01')
0 0
select from_unixtime(0); select from_unixtime(-1);
from_unixtime(0) from_unixtime(-1)
NULL NULL
select from_unixtime(2145916800); select from_unixtime(2145916800);
from_unixtime(2145916800) from_unixtime(2145916800)
NULL NULL
select from_unixtime(0);
from_unixtime(0)
1970-01-01 03:00:00
CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time); 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"); 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; SELECT * from t1;
......
...@@ -143,3 +143,13 @@ t ...@@ -143,3 +143,13 @@ t
0000-00-00 00:00:00 0000-00-00 00:00:00
2003-01-01 00:00:00 2003-01-01 00:00:00
drop table t1; drop table t1;
create table t1 (dt datetime);
insert into t1 values ("12-00-00"), ("00-00-00 01:00:00");
insert into t1 values ("00-00-00"), ("00-00-00 00:00:00");
select * from t1;
dt
2012-00-00 00:00:00
2000-00-00 01:00:00
0000-00-00 00:00:00
0000-00-00 00:00:00
drop table t1;
...@@ -231,10 +231,14 @@ select unix_timestamp('1969-12-01 19:00:01'); ...@@ -231,10 +231,14 @@ select unix_timestamp('1969-12-01 19:00:01');
# #
# Test for bug #6439 "unix_timestamp() function returns wrong datetime # Test for bug #6439 "unix_timestamp() function returns wrong datetime
# values for too big argument". It should return error instead. # values for too big argument" and bug #7515 "from_unixtime(0) now
# returns NULL instead of the epoch". unix_timestamp() should return error
# for too big or negative argument. It should return Epoch value for zero
# argument since it seems that many user's rely on this fact.
# #
select from_unixtime(0); select from_unixtime(-1);
select from_unixtime(2145916800); select from_unixtime(2145916800);
select from_unixtime(0);
# #
# Test types from + INTERVAL # Test types from + INTERVAL
......
...@@ -89,3 +89,15 @@ delete from t1; ...@@ -89,3 +89,15 @@ delete from t1;
insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer"); insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");
select * from t1; select * from t1;
drop table t1; drop table t1;
#
# Test for bug #7297 "Two digit year should be interpreted correctly even
# with zero month and day"
#
create table t1 (dt datetime);
# These dates should be treated as dates in 21st century
insert into t1 values ("12-00-00"), ("00-00-00 01:00:00");
# Zero dates are still special :/
insert into t1 values ("00-00-00"), ("00-00-00 00:00:00");
select * from t1;
drop table t1;
...@@ -1636,11 +1636,12 @@ longlong Item_func_from_unixtime::val_int() ...@@ -1636,11 +1636,12 @@ longlong Item_func_from_unixtime::val_int()
bool Item_func_from_unixtime::get_date(TIME *ltime, bool Item_func_from_unixtime::get_date(TIME *ltime,
uint fuzzy_date __attribute__((unused))) uint fuzzy_date __attribute__((unused)))
{ {
longlong tmp= args[0]->val_int(); ulonglong tmp= (ulonglong)(args[0]->val_int());
/*
if ((null_value= (args[0]->null_value || "tmp > TIMESTAMP_MAX_VALUE" check also covers case of negative
tmp < TIMESTAMP_MIN_VALUE || from_unixtime() argument since tmp is unsigned.
tmp > TIMESTAMP_MAX_VALUE))) */
if ((null_value= (args[0]->null_value || tmp > TIMESTAMP_MAX_VALUE)))
return 1; return 1;
thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)tmp); thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)tmp);
......
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