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
315b7d89
Commit
315b7d89
authored
Oct 21, 2004
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A fix (bug #6138: MOD operator should not round non-integral argument).
parent
0da47eae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
8 deletions
+27
-8
mysql-test/r/func_test.result
mysql-test/r/func_test.result
+9
-0
mysql-test/t/func_test.test
mysql-test/t/func_test.test
+13
-0
sql/item_func.cc
sql/item_func.cc
+5
-8
No files found.
mysql-test/r/func_test.result
View file @
315b7d89
...
...
@@ -174,3 +174,12 @@ SELECT GREATEST(d,d) FROM t1 WHERE k=2;
GREATEST(d,d)
NULL
DROP TABLE t1;
select 1197.90 mod 50;
1197.90 mod 50
47.90
select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3;
5.1 mod 3 5.1 mod -3 -5.1 mod 3 -5.1 mod -3
2.1 2.1 -2.1 -2.1
select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3;
5 mod 3 5 mod -3 -5 mod 3 -5 mod -3
2 2 -2 -2
mysql-test/t/func_test.test
View file @
315b7d89
...
...
@@ -94,3 +94,16 @@ CREATE TABLE t1 (d varchar(6), k int);
INSERT
INTO
t1
VALUES
(
NULL
,
2
);
SELECT
GREATEST
(
d
,
d
)
FROM
t1
WHERE
k
=
2
;
DROP
TABLE
t1
;
#
# Bug #6138: mod and doubles
#
select
1197.90
mod
50
;
select
5.1
mod
3
,
5.1
mod
-
3
,
-
5.1
mod
3
,
-
5.1
mod
-
3
;
#
# Test for mod and signed integers
#
select
5
mod
3
,
5
mod
-
3
,
-
5
mod
3
,
-
5
mod
-
3
;
sql/item_func.cc
View file @
315b7d89
...
...
@@ -651,11 +651,11 @@ void Item_func_int_div::fix_length_and_dec()
double
Item_func_mod
::
val
()
{
DBUG_ASSERT
(
fixed
==
1
);
double
value
=
floor
(
args
[
0
]
->
val
()
+
0.5
);
double
val2
=
floor
(
args
[
1
]
->
val
()
+
0.5
);
if
((
null_value
=
val2
==
0.0
||
args
[
0
]
->
null_value
||
args
[
1
]
->
null_value
))
double
x
=
args
[
0
]
->
val
(
);
double
y
=
args
[
1
]
->
val
(
);
if
((
null_value
=
(
y
==
0.0
)
||
args
[
0
]
->
null_value
||
args
[
1
]
->
null_value
))
return
0.0
;
/* purecov: inspected */
return
fmod
(
value
,
val2
);
return
fmod
(
x
,
y
);
}
longlong
Item_func_mod
::
val_int
()
...
...
@@ -670,10 +670,7 @@ longlong Item_func_mod::val_int()
void
Item_func_mod
::
fix_length_and_dec
()
{
max_length
=
args
[
1
]
->
max_length
;
decimals
=
0
;
maybe_null
=
1
;
find_num_type
();
Item_num_op
::
fix_length_and_dec
();
}
...
...
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