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
996f2808
Commit
996f2808
authored
Aug 15, 2008
by
Chad MILLER
Browse files
Options
Browse Files
Download
Plain Diff
Merge from 5.0-bugteam.
parents
037bc7e7
cebc2bf6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
7 deletions
+29
-7
mysql-test/r/type_newdecimal.result
mysql-test/r/type_newdecimal.result
+5
-0
mysql-test/t/type_newdecimal.test
mysql-test/t/type_newdecimal.test
+9
-0
strings/decimal.c
strings/decimal.c
+15
-7
No files found.
mysql-test/r/type_newdecimal.result
View file @
996f2808
...
@@ -1529,6 +1529,11 @@ SELECT f1 FROM t1;
...
@@ -1529,6 +1529,11 @@ SELECT f1 FROM t1;
f1
f1
99999999999999999999999999999.999999999999999999999999999999
99999999999999999999999999999.999999999999999999999999999999
DROP TABLE t1;
DROP TABLE t1;
select (1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 *
1.01500000 * 1.01500000 * 0.99500000);
(1.20396873 * 0.89550000 * 0.68000000 * 1.08721696 * 0.99500000 *
1.01500000 * 1.01500000 * 0.99500000)
0.812988073953673124592306939480
End of 5.0 tests
End of 5.0 tests
select cast(143.481 as decimal(4,1));
select cast(143.481 as decimal(4,1));
cast(143.481 as decimal(4,1))
cast(143.481 as decimal(4,1))
...
...
mysql-test/t/type_newdecimal.test
View file @
996f2808
...
@@ -1226,6 +1226,15 @@ DESC t1;
...
@@ -1226,6 +1226,15 @@ DESC t1;
SELECT
f1
FROM
t1
;
SELECT
f1
FROM
t1
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
#
# Bug #36270: incorrect calculation result - works in 4.1 but not in 5.0 or 5.1
#
# show that if we need to truncate the scale of an operand, we pick the
# right one (that is, we discard the least significant decimal places)
select
(
1.20396873
*
0.89550000
*
0.68000000
*
1.08721696
*
0.99500000
*
1.01500000
*
1.01500000
*
0.99500000
);
--
echo
End
of
5.0
tests
--
echo
End
of
5.0
tests
#
#
...
...
strings/decimal.c
View file @
996f2808
...
@@ -2005,18 +2005,18 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to)
...
@@ -2005,18 +2005,18 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to)
sanity
(
to
);
sanity
(
to
);
i
=
intg0
;
i
=
intg0
;
/* save 'ideal' values */
j
=
frac0
;
j
=
frac0
;
FIX_INTG_FRAC_ERROR
(
to
->
len
,
intg0
,
frac0
,
error
);
FIX_INTG_FRAC_ERROR
(
to
->
len
,
intg0
,
frac0
,
error
);
/* bound size */
to
->
sign
=
from1
->
sign
!=
from2
->
sign
;
to
->
sign
=
from1
->
sign
!=
from2
->
sign
;
to
->
frac
=
from1
->
frac
+
from2
->
frac
;
to
->
frac
=
from1
->
frac
+
from2
->
frac
;
/* store size in digits */
to
->
intg
=
intg0
*
DIG_PER_DEC1
;
to
->
intg
=
intg0
*
DIG_PER_DEC1
;
if
(
unlikely
(
error
))
if
(
unlikely
(
error
))
{
{
set_if_smaller
(
to
->
frac
,
frac0
*
DIG_PER_DEC1
);
set_if_smaller
(
to
->
frac
,
frac0
*
DIG_PER_DEC1
);
set_if_smaller
(
to
->
intg
,
intg0
*
DIG_PER_DEC1
);
set_if_smaller
(
to
->
intg
,
intg0
*
DIG_PER_DEC1
);
if
(
unlikely
(
i
>
intg0
))
if
(
unlikely
(
i
>
intg0
))
/* bounded integer-part */
{
{
i
-=
intg0
;
i
-=
intg0
;
j
=
i
>>
1
;
j
=
i
>>
1
;
...
@@ -2024,12 +2024,20 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to)
...
@@ -2024,12 +2024,20 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to)
intg2
-=
i
-
j
;
intg2
-=
i
-
j
;
frac1
=
frac2
=
0
;
/* frac0 is already 0 here */
frac1
=
frac2
=
0
;
/* frac0 is already 0 here */
}
}
else
else
/* bounded fract part */
{
{
j
-=
frac0
;
j
-=
frac0
;
i
=
j
>>
1
;
i
=
j
>>
1
;
frac1
-=
i
;
if
(
frac1
<=
frac2
)
frac2
-=
j
-
i
;
{
frac1
-=
i
;
frac2
-=
j
-
i
;
}
else
{
frac2
-=
i
;
frac1
-=
j
-
i
;
}
}
}
}
}
start0
=
to
->
buf
+
intg0
+
frac0
-
1
;
start0
=
to
->
buf
+
intg0
+
frac0
-
1
;
...
...
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