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
f0e9784c
Commit
f0e9784c
authored
Nov 27, 2008
by
Ingo Struewing
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
f1d4217a
9fd4cb9c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
14 deletions
+44
-14
mysql-test/r/func_sapdb.result
mysql-test/r/func_sapdb.result
+12
-0
mysql-test/t/func_sapdb.test
mysql-test/t/func_sapdb.test
+17
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+7
-7
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+3
-3
sql/item_func.cc
sql/item_func.cc
+1
-1
sql/item_timefunc.h
sql/item_timefunc.h
+1
-0
sql/my_decimal.cc
sql/my_decimal.cc
+1
-1
sql/mysql_priv.h
sql/mysql_priv.h
+2
-2
No files found.
mysql-test/r/func_sapdb.result
View file @
f0e9784c
...
...
@@ -256,3 +256,15 @@ a
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f");
str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f")
2003-01-02 10:11:12.001200
select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10'),time('00:00:00');
timediff('2008-09-29 20:10:10','2008-09-30 20:10:10') time('00:00:00')
-24:00:00 00:00:00
select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')>time('00:00:00');
timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')>time('00:00:00')
0
select timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00');
timediff('2008-09-29 20:10:10','2008-09-30 20:10:10')<time('00:00:00')
1
SELECT CAST(time('-73:42:12') AS DECIMAL);
CAST(time('-73:42:12') AS DECIMAL)
-734212
mysql-test/t/func_sapdb.test
View file @
f0e9784c
...
...
@@ -135,3 +135,20 @@ select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f");
--
enable_ps_protocol
# End of 4.1 tests
#
# Bug#37553: MySql Error Compare TimeDiff & Time
#
# calculations involving negative time values ignored sign
select
timediff
(
'2008-09-29 20:10:10'
,
'2008-09-30 20:10:10'
),
time
(
'00:00:00'
);
select
timediff
(
'2008-09-29 20:10:10'
,
'2008-09-30 20:10:10'
)
>
time
(
'00:00:00'
);
select
timediff
(
'2008-09-29 20:10:10'
,
'2008-09-30 20:10:10'
)
<
time
(
'00:00:00'
);
# show that conversion to DECIMAL no longer drops sign
SELECT
CAST
(
time
(
'-73:42:12'
)
AS
DECIMAL
);
# End of 5.0 tests
sql/item_cmpfunc.cc
View file @
f0e9784c
...
...
@@ -810,11 +810,11 @@ Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
obtained value
*/
u
longlong
longlong
get_time_value
(
THD
*
thd
,
Item
***
item_arg
,
Item
**
cache_arg
,
Item
*
warn_item
,
bool
*
is_null
)
{
u
longlong
value
;
longlong
value
;
Item
*
item
=
**
item_arg
;
MYSQL_TIME
ltime
;
...
...
@@ -826,7 +826,7 @@ get_time_value(THD *thd, Item ***item_arg, Item **cache_arg,
else
{
*
is_null
=
item
->
get_time
(
&
ltime
);
value
=
!*
is_null
?
TIME_to_ulonglong_datetime
(
&
ltime
)
:
0
;
value
=
!*
is_null
?
(
longlong
)
TIME_to_ulonglong_datetime
(
&
ltime
)
:
0
;
}
/*
Do not cache GET_USER_VAR() function as its const_item() may return TRUE
...
...
@@ -951,11 +951,11 @@ void Arg_comparator::set_datetime_cmp_func(Item **a1, Item **b1)
obtained value
*/
u
longlong
longlong
get_datetime_value
(
THD
*
thd
,
Item
***
item_arg
,
Item
**
cache_arg
,
Item
*
warn_item
,
bool
*
is_null
)
{
u
longlong
value
=
0
;
longlong
value
=
0
;
String
buf
,
*
str
=
0
;
Item
*
item
=
**
item_arg
;
...
...
@@ -993,7 +993,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
enum_field_types
f_type
=
warn_item
->
field_type
();
timestamp_type
t_type
=
f_type
==
MYSQL_TYPE_DATE
?
MYSQL_TIMESTAMP_DATE
:
MYSQL_TIMESTAMP_DATETIME
;
value
=
get_date_from_str
(
thd
,
str
,
t_type
,
warn_item
->
name
,
&
error
);
value
=
(
longlong
)
get_date_from_str
(
thd
,
str
,
t_type
,
warn_item
->
name
,
&
error
);
/*
If str did not contain a valid date according to the current
SQL_MODE, get_date_from_str() has already thrown a warning,
...
...
@@ -1047,7 +1047,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
int
Arg_comparator
::
compare_datetime
()
{
bool
a_is_null
,
b_is_null
;
u
longlong
a_value
,
b_value
;
longlong
a_value
,
b_value
;
/* Get DATE/DATETIME/TIME value of the 'a' item. */
a_value
=
(
*
get_value_func
)(
thd
,
&
a
,
&
a_cache
,
*
b
,
&
a_is_null
);
...
...
sql/item_cmpfunc.h
View file @
f0e9784c
...
...
@@ -42,8 +42,8 @@ class Arg_comparator: public Sql_alloc
bool
is_nulls_eq
;
// TRUE <=> compare for the EQUAL_FUNC
enum
enum_date_cmp_type
{
CMP_DATE_DFLT
=
0
,
CMP_DATE_WITH_DATE
,
CMP_DATE_WITH_STR
,
CMP_STR_WITH_DATE
};
u
longlong
(
*
get_value_func
)(
THD
*
thd
,
Item
***
item_arg
,
Item
**
cache_arg
,
Item
*
warn_item
,
bool
*
is_null
);
longlong
(
*
get_value_func
)(
THD
*
thd
,
Item
***
item_arg
,
Item
**
cache_arg
,
Item
*
warn_item
,
bool
*
is_null
);
public:
DTCollation
cmp_collation
;
...
...
@@ -1012,7 +1012,7 @@ class cmp_item_int :public cmp_item
*/
class
cmp_item_datetime
:
public
cmp_item
{
u
longlong
value
;
longlong
value
;
public:
THD
*
thd
;
/* Item used for issuing warnings. */
...
...
sql/item_func.cc
View file @
f0e9784c
...
...
@@ -2267,7 +2267,7 @@ uint Item_func_min_max::cmp_datetimes(ulonglong *value)
{
Item
**
arg
=
args
+
i
;
bool
is_null
;
u
longlong
res
=
get_datetime_value
(
thd
,
&
arg
,
0
,
datetime_item
,
&
is_null
);
longlong
res
=
get_datetime_value
(
thd
,
&
arg
,
0
,
datetime_item
,
&
is_null
);
if
((
null_value
=
args
[
i
]
->
null_value
))
return
0
;
if
(
i
==
0
||
(
res
<
min_max
?
cmp_sign
:
-
cmp_sign
)
>
0
)
...
...
sql/item_timefunc.h
View file @
f0e9784c
...
...
@@ -429,6 +429,7 @@ class Item_str_timefunc :public Item_str_func
{
return
save_time_in_field
(
field
);
}
bool
result_as_longlong
()
{
return
TRUE
;
}
};
...
...
sql/my_decimal.cc
View file @
f0e9784c
...
...
@@ -214,7 +214,7 @@ my_decimal *date2my_decimal(MYSQL_TIME *ltime, my_decimal *dec)
date
=
(
ltime
->
year
*
100L
+
ltime
->
month
)
*
100L
+
ltime
->
day
;
if
(
ltime
->
time_type
>
MYSQL_TIMESTAMP_DATE
)
date
=
((
date
*
100L
+
ltime
->
hour
)
*
100L
+
ltime
->
minute
)
*
100L
+
ltime
->
second
;
if
(
int2my_decimal
(
E_DEC_FATAL_ERROR
,
date
,
FALSE
,
dec
))
if
(
int2my_decimal
(
E_DEC_FATAL_ERROR
,
ltime
->
neg
?
-
date
:
date
,
FALSE
,
dec
))
return
dec
;
if
(
ltime
->
second_part
)
{
...
...
sql/mysql_priv.h
View file @
f0e9784c
...
...
@@ -2175,8 +2175,8 @@ void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
void
make_time
(
const
DATE_TIME_FORMAT
*
format
,
const
MYSQL_TIME
*
l_time
,
String
*
str
);
int
my_time_compare
(
MYSQL_TIME
*
a
,
MYSQL_TIME
*
b
);
u
longlong
get_datetime_value
(
THD
*
thd
,
Item
***
item_arg
,
Item
**
cache_arg
,
Item
*
warn_item
,
bool
*
is_null
);
longlong
get_datetime_value
(
THD
*
thd
,
Item
***
item_arg
,
Item
**
cache_arg
,
Item
*
warn_item
,
bool
*
is_null
);
int
test_if_number
(
char
*
str
,
int
*
res
,
bool
allow_wildcards
);
void
change_byte
(
uchar
*
,
uint
,
char
,
char
);
...
...
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