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
ad1094ba
Commit
ad1094ba
authored
Feb 07, 2006
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com.:/data/BK/mysql-5.0
into mysql.com.:/data/BK/mysql-5.0_8461_b
parents
96ead39d
05f658a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
16 deletions
+47
-16
mysql-test/r/func_math.result
mysql-test/r/func_math.result
+15
-0
mysql-test/t/func_math.test
mysql-test/t/func_math.test
+14
-0
sql/item_func.cc
sql/item_func.cc
+18
-16
No files found.
mysql-test/r/func_math.result
View file @
ad1094ba
...
...
@@ -203,3 +203,18 @@ NULL
Warnings:
Error 1365 Division by 0
set sql_mode='';
select round(111,-10);
round(111,-10)
0
select round(-5000111000111000155,-1);
round(-5000111000111000155,-1)
-5000111000111000160
select round(15000111000111000155,-1);
round(15000111000111000155,-1)
15000111000111000160
select truncate(-5000111000111000155,-1);
truncate(-5000111000111000155,-1)
-5000111000111000150
select truncate(15000111000111000155,-1);
truncate(15000111000111000155,-1)
15000111000111000150
mysql-test/t/func_math.test
View file @
ad1094ba
...
...
@@ -141,3 +141,17 @@ select log(2,-1);
select
log
(
-
2
,
1
);
set
sql_mode
=
''
;
#
# Bug #8461 truncate() and round() return false results 2nd argument negative.
#
# round(a,-b) log_10(b) > a
select
round
(
111
,
-
10
);
# round on bigint
select
round
(
-
5000111000111000155
,
-
1
);
# round on unsigned bigint
select
round
(
15000111000111000155
,
-
1
);
# truncate on bigint
select
truncate
(
-
5000111000111000155
,
-
1
);
# truncate on unsigned bigint
select
truncate
(
15000111000111000155
,
-
1
);
sql/item_func.cc
View file @
ad1094ba
...
...
@@ -1863,28 +1863,30 @@ longlong Item_func_round::int_op()
return
value
;
// integer have not digits after point
abs_dec
=
-
dec
;
double
tmp
;
/*
tmp2 is here to avoid return the value with 80 bit precision
This will fix that the test round(0.1,1) = round(0.1,1) is true
*/
volatile
double
tmp2
;
tmp
=
(
abs_dec
<
array_elements
(
log_10
)
?
log_10
[
abs_dec
]
:
pow
(
10.0
,
(
double
)
abs_dec
));
longlong
tmp
;
if
(
abs_dec
>=
array_elements
(
log_10_int
))
return
0
;
tmp
=
log_10_int
[
abs_dec
];
if
(
truncate
)
{
if
(
unsigned_flag
)
tmp2
=
floor
(
ulonglong2double
(
value
)
/
tmp
)
*
tmp
;
else
if
(
value
>=
0
)
tmp2
=
floor
(((
double
)
value
)
/
tmp
)
*
tmp
;
value
=
(
ulonglong
(
value
)
/
tmp
)
*
tmp
;
else
tmp2
=
ceil
(((
double
)
value
)
/
tmp
)
*
tmp
;
value
=
(
value
/
tmp
)
*
tmp
;
}
else
tmp2
=
rint
(((
double
)
value
)
/
tmp
)
*
tmp
;
return
(
longlong
)
tmp2
;
{
if
(
unsigned_flag
)
value
=
((
ulonglong
(
value
)
+
(
tmp
>>
1
))
/
tmp
)
*
tmp
;
else
if
(
value
>=
0
)
value
=
((
value
+
(
tmp
>>
1
))
/
tmp
)
*
tmp
;
else
value
=
((
value
-
(
tmp
>>
1
))
/
tmp
)
*
tmp
;
}
return
value
;
}
...
...
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