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
50579df6
Commit
50579df6
authored
May 06, 2005
by
ramil@ram-book.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A fix (bug #10404: select 0/0 returns 0).
parent
5496b7ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
13 deletions
+24
-13
mysql-test/r/type_newdecimal.result
mysql-test/r/type_newdecimal.result
+4
-0
mysql-test/t/type_newdecimal.test
mysql-test/t/type_newdecimal.test
+7
-0
strings/decimal.c
strings/decimal.c
+13
-13
No files found.
mysql-test/r/type_newdecimal.result
View file @
50579df6
...
...
@@ -842,3 +842,7 @@ drop table Sow6_2f;
select 10.3330000000000/12.34500000;
10.3330000000000/12.34500000
0.83701903604698258
set sql_mode='';
select 0/0;
0/0
NULL
mysql-test/t/type_newdecimal.test
View file @
50579df6
...
...
@@ -869,3 +869,10 @@ drop table Sow6_2f;
# bug#9501
#
select
10.3330000000000
/
12.34500000
;
#
# Bug #10404
#
set
sql_mode
=
''
;
select
0
/
0
;
strings/decimal.c
View file @
50579df6
...
...
@@ -1945,6 +1945,18 @@ static int do_div_mod(decimal_t *from1, decimal_t *from2,
sanity
(
to
);
/* removing all the leading zeroes */
i
=
((
prec2
-
1
)
%
DIG_PER_DEC1
)
+
1
;
while
(
prec2
>
0
&&
*
buf2
==
0
)
{
prec2
-=
i
;
i
=
DIG_PER_DEC1
;
buf2
++
;
}
if
(
prec2
<=
0
)
/* short-circuit everything: from2 == 0 */
return
E_DEC_DIV_ZERO
;
for
(
i
=
(
prec2
-
1
)
%
DIG_PER_DEC1
;
*
buf2
<
powers10
[
i
--
];
prec2
--
)
;
DBUG_ASSERT
(
prec2
>
0
);
i
=
((
prec1
-
1
)
%
DIG_PER_DEC1
)
+
1
;
while
(
prec1
>
0
&&
*
buf1
==
0
)
{
...
...
@@ -1960,19 +1972,6 @@ static int do_div_mod(decimal_t *from1, decimal_t *from2,
for
(
i
=
(
prec1
-
1
)
%
DIG_PER_DEC1
;
*
buf1
<
powers10
[
i
--
];
prec1
--
)
;
DBUG_ASSERT
(
prec1
>
0
);
i
=
((
prec2
-
1
)
%
DIG_PER_DEC1
)
+
1
;
while
(
prec2
>
0
&&
*
buf2
==
0
)
{
prec2
-=
i
;
i
=
DIG_PER_DEC1
;
buf2
++
;
}
if
(
prec2
<=
0
)
/* short-circuit everything: from2 == 0 */
return
E_DEC_DIV_ZERO
;
for
(
i
=
(
prec2
-
1
)
%
DIG_PER_DEC1
;
*
buf2
<
powers10
[
i
--
];
prec2
--
)
;
DBUG_ASSERT
(
prec2
>
0
);
/* let's fix scale_incr, taking into account frac1,frac2 increase */
if
((
scale_incr
-=
frac1
-
from1
->
frac
+
frac2
-
from2
->
frac
)
<
0
)
scale_incr
=
0
;
...
...
@@ -2723,6 +2722,7 @@ int main()
test_dv
(
"123"
,
"0.01"
,
"12300.000000000"
,
0
);
test_dv
(
"120"
,
"100000000000.00000"
,
"0.000000001200000000"
,
0
);
test_dv
(
"123"
,
"0"
,
""
,
4
);
test_dv
(
"0"
,
"0"
,
""
,
4
);
test_dv
(
"-12193185.1853376"
,
"98765.4321"
,
"-123.456000000000000000"
,
0
);
test_dv
(
"121931851853376"
,
"987654321"
,
"123456.000000000"
,
0
);
test_dv
(
"0"
,
"987"
,
"0"
,
0
);
...
...
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