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
299b29b2
Commit
299b29b2
authored
Mar 19, 2011
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lp:738091 cast(timestamp() AS time returns NULL for 0000-00-00 00:00:00 in 5.1-micro
parent
a67bf98f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
6 deletions
+29
-6
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
+9
-0
sql/field.cc
sql/field.cc
+14
-6
No files found.
mysql-test/r/func_time.result
View file @
299b29b2
...
...
@@ -1539,3 +1539,9 @@ NULL
select timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'));
timestamp(greatest('2002-08-20', '0000-00-00 00:00:00'))
2002-08-20 00:00:00
create table t1 (f1 datetime);
insert into t1 values ('0000-00-00 00:00:00');
select cast(f1 AS time) from t1;
cast(f1 AS time)
00:00:00
drop table t1;
mysql-test/t/func_time.test
View file @
299b29b2
...
...
@@ -977,3 +977,12 @@ select day(coalesce(null));
# lp:738067 Crash in get_datetime_value() in 5.1-micro
#
select
timestamp
(
greatest
(
'2002-08-20'
,
'0000-00-00 00:00:00'
));
#
# lp:738091 cast(timestamp() AS time returns NULL for 0000-00-00 00:00:00 in 5.1-micro
#
create
table
t1
(
f1
datetime
);
insert
into
t1
values
(
'0000-00-00 00:00:00'
);
select
cast
(
f1
AS
time
)
from
t1
;
drop
table
t1
;
sql/field.cc
View file @
299b29b2
...
...
@@ -5870,10 +5870,10 @@ bool Field_newdate::get_date(MYSQL_TIME *ltime,uint fuzzydate)
ltime
->
year
=
(
tmp
>>
9
);
ltime
->
time_type
=
MYSQL_TIMESTAMP_DATE
;
ltime
->
hour
=
ltime
->
minute
=
ltime
->
second
=
ltime
->
second_part
=
ltime
->
neg
=
0
;
if
(
(
fuzzydate
&
TIME_NO_ZERO_DATE
)
&&
!
tmp
)
return
1
;
if
(
!
(
fuzzydate
&
TIME_FUZZY_DATE
)
&&
(
!
ltime
->
month
||
!
ltime
->
day
)
)
return
1
;
if
(
!
tmp
)
return
fuzzydate
&
TIME_NO_ZERO_DATE
;
if
(
!
ltime
->
month
||
!
ltime
->
day
)
return
!
(
fuzzydate
&
TIME_FUZZY_DATE
)
;
return
0
;
}
...
...
@@ -6003,7 +6003,11 @@ bool Field_datetime::get_date(MYSQL_TIME *ltime, uint fuzzydate)
ltime
->
day
=
(
int
)
(
part1
%
100
);
ltime
->
month
=
(
int
)
(
part1
/
100
%
100
);
ltime
->
year
=
(
int
)
(
part1
/
10000
);
return
(
!
(
fuzzydate
&
TIME_FUZZY_DATE
)
&&
(
!
ltime
->
month
||
!
ltime
->
day
))
?
1
:
0
;
if
(
!
tmp
)
return
fuzzydate
&
TIME_NO_ZERO_DATE
;
if
(
!
ltime
->
month
||
!
ltime
->
day
)
return
!
(
fuzzydate
&
TIME_FUZZY_DATE
);
return
0
;
}
int
Field_datetime
::
cmp
(
const
uchar
*
a_ptr
,
const
uchar
*
b_ptr
)
...
...
@@ -6110,7 +6114,11 @@ bool Field_datetime_hires::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{
ulonglong
packed
=
read_bigendian
(
ptr
,
Field_datetime_hires
::
pack_length
());
unpack_time
(
sec_part_unshift
(
packed
,
dec
),
ltime
);
return
(
!
(
fuzzydate
&
TIME_FUZZY_DATE
)
&&
(
!
ltime
->
month
||
!
ltime
->
day
))
?
1
:
0
;
if
(
!
packed
)
return
fuzzydate
&
TIME_NO_ZERO_DATE
;
if
(
!
ltime
->
month
||
!
ltime
->
day
)
return
!
(
fuzzydate
&
TIME_FUZZY_DATE
);
return
0
;
}
uint32
Field_datetime_hires
::
pack_length
()
const
...
...
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