Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
2878395a
Commit
2878395a
authored
Dec 30, 2004
by
dlenev@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for bug #7515 "from_unixtime(0) now returns NULL instead of
the Epoch". (With after review fixes).
parent
aeaeb3f0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
10 deletions
+18
-10
mysql-test/r/func_time.result
mysql-test/r/func_time.result
+5
-2
mysql-test/t/func_time.test
mysql-test/t/func_time.test
+6
-2
sql/item_timefunc.cc
sql/item_timefunc.cc
+6
-4
sql/item_timefunc.h
sql/item_timefunc.h
+1
-2
No files found.
mysql-test/r/func_time.result
View file @
2878395a
...
@@ -470,9 +470,12 @@ unix_timestamp(@a)
...
@@ -470,9 +470,12 @@ 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
mysql-test/t/func_time.test
View file @
2878395a
...
@@ -228,7 +228,11 @@ select unix_timestamp('1969-12-01 19:00:01');
...
@@ -228,7 +228,11 @@ 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
);
sql/item_timefunc.cc
View file @
2878395a
...
@@ -946,10 +946,12 @@ bool Item_func_from_unixtime::get_date(TIME *ltime,
...
@@ -946,10 +946,12 @@ bool Item_func_from_unixtime::get_date(TIME *ltime,
{
{
struct
tm
tm_tmp
;
struct
tm
tm_tmp
;
time_t
tmp
;
time_t
tmp
;
longlong
arg
=
args
[
0
]
->
val_int
();
ulonglong
arg
=
(
ulonglong
)(
args
[
0
]
->
val_int
());
if
((
null_value
=
(
args
[
0
]
->
null_value
||
/*
arg
<
TIMESTAMP_MIN_VALUE
||
"arg > TIMESTAMP_MAX_VALUE" check also covers case of negative
arg
>
TIMESTAMP_MAX_VALUE
)))
from_unixtime() argument since arg is unsigned.
*/
if
((
null_value
=
(
args
[
0
]
->
null_value
||
arg
>
TIMESTAMP_MAX_VALUE
)))
return
1
;
return
1
;
tmp
=
arg
;
tmp
=
arg
;
localtime_r
(
&
tmp
,
&
tm_tmp
);
localtime_r
(
&
tmp
,
&
tm_tmp
);
...
...
sql/item_timefunc.h
View file @
2878395a
...
@@ -359,8 +359,7 @@ class Item_func_from_unixtime :public Item_date_func
...
@@ -359,8 +359,7 @@ class Item_func_from_unixtime :public Item_date_func
longlong
val_int
();
longlong
val_int
();
String
*
val_str
(
String
*
str
);
String
*
val_str
(
String
*
str
);
const
char
*
func_name
()
const
{
return
"from_unixtime"
;
}
const
char
*
func_name
()
const
{
return
"from_unixtime"
;
}
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
19
;
}
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
19
;
maybe_null
=
1
;
}
// enum Item_result result_type () const { return STRING_RESULT; }
bool
get_date
(
TIME
*
res
,
bool
fuzzy_date
);
bool
get_date
(
TIME
*
res
,
bool
fuzzy_date
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment