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
e595b7ee
Commit
e595b7ee
authored
Jun 08, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/hf/work/mysql-5.0.8459
parents
5c6143b6
4408350b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
13 deletions
+52
-13
mysql-test/r/func_math.result
mysql-test/r/func_math.result
+13
-0
mysql-test/t/func_math.test
mysql-test/t/func_math.test
+12
-0
sql/item_strfunc.cc
sql/item_strfunc.cc
+27
-13
No files found.
mysql-test/r/func_math.result
View file @
e595b7ee
...
...
@@ -130,3 +130,16 @@ Warnings:
Note 1003 select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)`
select rand(rand);
ERROR 42S22: Unknown column 'rand' in 'field list'
create table t1 (col1 int, col2 decimal(60,30));
insert into t1 values(1,1234567890.12345);
select format(col2,7) from t1;
format(col2,7)
1,234,567,890.1234500
select format(col2,8) from t1;
format(col2,8)
1,234,567,890.12345000
insert into t1 values(7,1234567890123456.12345);
select format(col2,6) from t1 where col1=7;
format(col2,6)
1,234,567,890,123,456.123450
drop table t1;
mysql-test/t/func_math.test
View file @
e595b7ee
...
...
@@ -67,3 +67,15 @@ explain extended select degrees(pi()),radians(360);
--
error
1054
select
rand
(
rand
);
#
# Bug #8459 (FORMAT returns incorrect result)
#
create
table
t1
(
col1
int
,
col2
decimal
(
60
,
30
));
insert
into
t1
values
(
1
,
1234567890.12345
);
select
format
(
col2
,
7
)
from
t1
;
select
format
(
col2
,
8
)
from
t1
;
insert
into
t1
values
(
7
,
1234567890123456.12345
);
select
format
(
col2
,
6
)
from
t1
where
col1
=
7
;
drop
table
t1
;
sql/item_strfunc.cc
View file @
e595b7ee
...
...
@@ -1668,22 +1668,36 @@ Item_func_format::Item_func_format(Item *org,int dec) :Item_str_func(org)
String
*
Item_func_format
::
val_str
(
String
*
str
)
{
DBUG_ASSERT
(
fixed
==
1
);
double
nr
=
args
[
0
]
->
val_real
();
uint32
length
,
str_length
,
dec
;
uint32
length
,
str_length
,
dec
;
int
diff
;
if
((
null_value
=
args
[
0
]
->
null_value
))
return
0
;
/* purecov: inspected */
nr
=
my_double_round
(
nr
,
decimals
,
FALSE
);
DBUG_ASSERT
(
fixed
==
1
);
dec
=
decimals
?
decimals
+
1
:
0
;
/* Here default_charset() is right as this is not an automatic conversion */
str
->
set
(
nr
,
decimals
,
default_charset
());
if
(
isnan
(
nr
))
return
str
;
str_length
=
str
->
length
();
if
(
nr
<
0
)
str_length
--
;
// Don't count sign
if
(
args
[
0
]
->
result_type
()
==
DECIMAL_RESULT
||
args
[
0
]
->
result_type
()
==
INT_RESULT
)
{
my_decimal
dec_val
,
rnd_dec
,
*
res
;
res
=
args
[
0
]
->
val_decimal
(
&
dec_val
);
my_decimal_round
(
E_DEC_FATAL_ERROR
,
res
,
decimals
,
false
,
&
rnd_dec
);
my_decimal2string
(
E_DEC_FATAL_ERROR
,
&
rnd_dec
,
0
,
0
,
0
,
str
);
str_length
=
str
->
length
();
if
(
rnd_dec
.
sign
())
str_length
--
;
}
else
{
double
nr
=
args
[
0
]
->
val_real
();
if
((
null_value
=
args
[
0
]
->
null_value
))
return
0
;
/* purecov: inspected */
nr
=
my_double_round
(
nr
,
decimals
,
FALSE
);
/* Here default_charset() is right as this is not an automatic conversion */
str
->
set
(
nr
,
decimals
,
default_charset
());
if
(
isnan
(
nr
))
return
str
;
str_length
=
str
->
length
();
if
(
nr
<
0
)
str_length
--
;
// Don't count sign
}
/* We need this test to handle 'nan' values */
if
(
str_length
>=
dec
+
4
)
{
...
...
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