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
971eaa18
Commit
971eaa18
authored
Jun 15, 2005
by
hf@deer.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for bug #10337 (cast(NULL DECIMAL) crashes the server)
parent
66591aea
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
2 deletions
+24
-2
mysql-test/r/cast.result
mysql-test/r/cast.result
+3
-0
mysql-test/t/cast.test
mysql-test/t/cast.test
+6
-0
sql/item_func.cc
sql/item_func.cc
+8
-1
strings/decimal.c
strings/decimal.c
+7
-1
No files found.
mysql-test/r/cast.result
View file @
971eaa18
...
@@ -344,3 +344,6 @@ select cast(s1 as decimal(7,2)) from t1;
...
@@ -344,3 +344,6 @@ select cast(s1 as decimal(7,2)) from t1;
cast(s1 as decimal(7,2))
cast(s1 as decimal(7,2))
111111.00
111111.00
drop table t1;
drop table t1;
select cast(NULL as decimal(6)) as t1;
t1
NULL
mysql-test/t/cast.test
View file @
971eaa18
...
@@ -168,3 +168,9 @@ create table t1(s1 time);
...
@@ -168,3 +168,9 @@ create table t1(s1 time);
insert
into
t1
values
(
'11:11:11'
);
insert
into
t1
values
(
'11:11:11'
);
select
cast
(
s1
as
decimal
(
7
,
2
))
from
t1
;
select
cast
(
s1
as
decimal
(
7
,
2
))
from
t1
;
drop
table
t1
;
drop
table
t1
;
#
# Bug @10237 (CAST(NULL DECIMAL) crashes server)
#
select
cast
(
NULL
as
decimal
(
6
))
as
t1
;
sql/item_func.cc
View file @
971eaa18
...
@@ -1022,7 +1022,8 @@ longlong Item_func_unsigned::val_int()
...
@@ -1022,7 +1022,8 @@ longlong Item_func_unsigned::val_int()
String
*
Item_decimal_typecast
::
val_str
(
String
*
str
)
String
*
Item_decimal_typecast
::
val_str
(
String
*
str
)
{
{
my_decimal
tmp_buf
,
*
tmp
=
val_decimal
(
&
tmp_buf
);
my_decimal
tmp_buf
,
*
tmp
=
val_decimal
(
&
tmp_buf
);
my_decimal_round
(
E_DEC_FATAL_ERROR
,
tmp
,
decimals
,
FALSE
,
&
tmp_buf
);
if
(
null_value
)
return
NULL
;
my_decimal2string
(
E_DEC_FATAL_ERROR
,
&
tmp_buf
,
0
,
0
,
0
,
str
);
my_decimal2string
(
E_DEC_FATAL_ERROR
,
&
tmp_buf
,
0
,
0
,
0
,
str
);
return
str
;
return
str
;
}
}
...
@@ -1032,6 +1033,8 @@ double Item_decimal_typecast::val_real()
...
@@ -1032,6 +1033,8 @@ double Item_decimal_typecast::val_real()
{
{
my_decimal
tmp_buf
,
*
tmp
=
val_decimal
(
&
tmp_buf
);
my_decimal
tmp_buf
,
*
tmp
=
val_decimal
(
&
tmp_buf
);
double
res
;
double
res
;
if
(
null_value
)
return
0.0
;
my_decimal2double
(
E_DEC_FATAL_ERROR
,
tmp
,
&
res
);
my_decimal2double
(
E_DEC_FATAL_ERROR
,
tmp
,
&
res
);
return
res
;
return
res
;
}
}
...
@@ -1041,6 +1044,8 @@ longlong Item_decimal_typecast::val_int()
...
@@ -1041,6 +1044,8 @@ longlong Item_decimal_typecast::val_int()
{
{
my_decimal
tmp_buf
,
*
tmp
=
val_decimal
(
&
tmp_buf
);
my_decimal
tmp_buf
,
*
tmp
=
val_decimal
(
&
tmp_buf
);
longlong
res
;
longlong
res
;
if
(
null_value
)
return
0
;
my_decimal2int
(
E_DEC_FATAL_ERROR
,
tmp
,
unsigned_flag
,
&
res
);
my_decimal2int
(
E_DEC_FATAL_ERROR
,
tmp
,
unsigned_flag
,
&
res
);
return
res
;
return
res
;
}
}
...
@@ -1049,6 +1054,8 @@ longlong Item_decimal_typecast::val_int()
...
@@ -1049,6 +1054,8 @@ longlong Item_decimal_typecast::val_int()
my_decimal
*
Item_decimal_typecast
::
val_decimal
(
my_decimal
*
dec
)
my_decimal
*
Item_decimal_typecast
::
val_decimal
(
my_decimal
*
dec
)
{
{
my_decimal
tmp_buf
,
*
tmp
=
args
[
0
]
->
val_decimal
(
&
tmp_buf
);
my_decimal
tmp_buf
,
*
tmp
=
args
[
0
]
->
val_decimal
(
&
tmp_buf
);
if
((
null_value
=
args
[
0
]
->
null_value
))
return
NULL
;
my_decimal_round
(
E_DEC_FATAL_ERROR
,
tmp
,
decimals
,
FALSE
,
dec
);
my_decimal_round
(
E_DEC_FATAL_ERROR
,
tmp
,
decimals
,
FALSE
,
dec
);
return
dec
;
return
dec
;
}
}
...
...
strings/decimal.c
View file @
971eaa18
...
@@ -1563,7 +1563,13 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
...
@@ -1563,7 +1563,13 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
break
;
break
;
if
(
buf1
--
==
to
->
buf
)
if
(
buf1
--
==
to
->
buf
)
{
{
decimal_make_zero
(
to
);
/* making 'zero' with the proper scale */
dec1
*
p0
=
to
->
buf
+
frac0
+
1
;
to
->
intg
=
1
;
to
->
frac
=
max
(
scale
,
0
);
to
->
sign
=
0
;
for
(
buf1
=
to
->
buf
;
buf1
<
p0
;
buf1
++
)
*
buf1
=
0
;
return
E_DEC_OK
;
return
E_DEC_OK
;
}
}
}
}
...
...
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