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
76bc6771
Commit
76bc6771
authored
May 11, 2004
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug#3612 - Item_func_div set decimals incorrectly
parent
2b4a56b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
0 deletions
+24
-0
mysql-test/r/type_float.result
mysql-test/r/type_float.result
+15
-0
mysql-test/t/type_float.test
mysql-test/t/type_float.test
+8
-0
sql/item_func.cc
sql/item_func.cc
+1
-0
No files found.
mysql-test/r/type_float.result
View file @
76bc6771
...
...
@@ -67,6 +67,21 @@ select min(a) from t1;
min(a)
-0.010
drop table t1;
create table t1 (c1 double, c2 varchar(20));
insert t1 values (121,"16");
select c1 + c1 * (c2 / 100) as col from t1;
col
140.36
create table t2 select c1 + c1 * (c2 / 100) as col from t1;
select * from t2;
col
140.36
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`col` double default NULL
) TYPE=MyISAM
drop table t1,t2;
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6));
show full columns from t1;
Field Type Null Key Default Extra Privileges
...
...
mysql-test/t/type_float.test
View file @
76bc6771
...
...
@@ -28,6 +28,14 @@ select a from t1 order by a;
select
min
(
a
)
from
t1
;
drop
table
t1
;
create
table
t1
(
c1
double
,
c2
varchar
(
20
));
insert
t1
values
(
121
,
"16"
);
select
c1
+
c1
*
(
c2
/
100
)
as
col
from
t1
;
create
table
t2
select
c1
+
c1
*
(
c2
/
100
)
as
col
from
t1
;
select
*
from
t2
;
show
create
table
t2
;
drop
table
t1
,
t2
;
#
# FLOAT/DOUBLE/DECIMAL handling
#
...
...
sql/item_func.cc
View file @
76bc6771
...
...
@@ -402,6 +402,7 @@ longlong Item_func_div::val_int()
void
Item_func_div
::
fix_length_and_dec
()
{
decimals
=
max
(
args
[
0
]
->
decimals
,
args
[
1
]
->
decimals
)
+
2
;
set_if_smaller
(
decimals
,
NOT_FIXED_DEC
);
max_length
=
args
[
0
]
->
max_length
-
args
[
0
]
->
decimals
+
decimals
;
uint
tmp
=
float_length
(
decimals
);
set_if_smaller
(
max_length
,
tmp
);
...
...
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