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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
801a2fa3
Commit
801a2fa3
authored
Nov 19, 2004
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-4.0
into mysql.com:/home/dlenev/src/mysql-4.0-bg6439
parents
f336c62a
e1509cf7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
34 deletions
+36
-34
mysql-test/r/func_time.result
mysql-test/r/func_time.result
+6
-0
mysql-test/t/func_time.test
mysql-test/t/func_time.test
+7
-0
sql/item_timefunc.cc
sql/item_timefunc.cc
+23
-34
No files found.
mysql-test/r/func_time.result
View file @
801a2fa3
...
...
@@ -470,3 +470,9 @@ 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
mysql-test/t/func_time.test
View file @
801a2fa3
...
...
@@ -225,3 +225,10 @@ drop table t1,t2,t3;
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
);
sql/item_timefunc.cc
View file @
801a2fa3
...
...
@@ -919,21 +919,14 @@ String *Item_func_date_format::val_str(String *str)
String
*
Item_func_from_unixtime
::
val_str
(
String
*
str
)
{
struct
tm
tm_tmp
,
*
start
;
time_t
tmp
=
(
time_t
)
args
[
0
]
->
val_int
();
if
((
null_value
=
args
[
0
]
->
null_value
))
TIME
ltime
;
if
(
get_date
(
&
ltime
,
0
))
return
0
;
localtime_r
(
&
tmp
,
&
tm_tmp
);
start
=&
tm_tmp
;
if
(
str
->
alloc
(
20
))
return
str
;
/* purecov: inspected */
sprintf
((
char
*
)
str
->
ptr
(),
"%04d-%02d-%02d %02d:%02d:%02d"
,
(
int
)
start
->
tm_year
+
1900
,
(
int
)
start
->
tm_mon
+
1
,
(
int
)
start
->
tm_mday
,
(
int
)
start
->
tm_hour
,
(
int
)
start
->
tm_min
,
(
int
)
start
->
tm_sec
);
(
int
)
ltime
.
year
,
(
int
)
ltime
.
month
,
(
int
)
ltime
.
day
,
(
int
)
ltime
.
hour
,
(
int
)
ltime
.
minute
,
(
int
)
ltime
.
second
);
str
->
length
(
19
);
return
str
;
}
...
...
@@ -941,37 +934,33 @@ String *Item_func_from_unixtime::val_str(String *str)
longlong
Item_func_from_unixtime
::
val_int
()
{
time_t
tmp
=
(
time_t
)
(
ulong
)
args
[
0
]
->
val_int
()
;
if
(
(
null_value
=
args
[
0
]
->
null_value
))
TIME
ltime
;
if
(
get_date
(
&
ltime
,
0
))
return
0
;
struct
tm
tm_tmp
,
*
start
;
localtime_r
(
&
tmp
,
&
tm_tmp
);
start
=
&
tm_tmp
;
return
((
longlong
)
((
ulong
)
((
uint
)
start
->
tm_year
+
1900
)
*
10000L
+
(((
uint
)
start
->
tm_mon
+
1
)
*
100
+
(
uint
)
start
->
tm_mday
))
*
LL
(
1000000
)
+
(
longlong
)
((
ulong
)
((
uint
)
start
->
tm_hour
)
*
10000L
+
(
ulong
)
(((
uint
)
start
->
tm_min
)
*
100L
+
(
uint
)
start
->
tm_sec
)));
return
((
longlong
)(
ltime
.
year
*
10000L
+
ltime
.
month
*
100
+
ltime
.
day
)
*
LL
(
1000000
)
+
(
longlong
)(
ltime
.
hour
*
10000L
+
ltime
.
minute
*
100
+
ltime
.
second
));
}
bool
Item_func_from_unixtime
::
get_date
(
TIME
*
ltime
,
bool
fuzzy_date
__attribute__
((
unused
)))
{
time_t
tmp
=
(
time_t
)
(
ulong
)
args
[
0
]
->
val_int
();
if
((
null_value
=
args
[
0
]
->
null_value
))
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
)))
return
1
;
struct
tm
tm_tmp
,
*
start
;
tmp
=
arg
;
localtime_r
(
&
tmp
,
&
tm_tmp
);
start
=
&
tm_tmp
;
ltime
->
year
=
start
->
tm_year
+
1900
;
ltime
->
month
=
start
->
tm_mon
+
1
;
ltime
->
day
=
start
->
tm_mday
;
ltime
->
hour
=
start
->
tm_hour
;
ltime
->
minute
=
start
->
tm_min
;
ltime
->
second
=
start
->
tm_sec
;
ltime
->
second_part
=
0
;
ltime
->
neg
=
0
;
ltime
->
year
=
tm_tmp
.
tm_year
+
1900
;
ltime
->
month
=
tm_tmp
.
tm_mon
+
1
;
ltime
->
day
=
tm_tmp
.
tm_mday
;
ltime
->
hour
=
tm_tmp
.
tm_hour
;
ltime
->
minute
=
tm_tmp
.
tm_min
;
ltime
->
second
=
tm_tmp
.
tm_sec
;
ltime
->
second_part
=
0
;
ltime
->
neg
=
0
;
return
0
;
}
...
...
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