Below is the list of changes that have just been committed into a local
5.0 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1943 05/06/15 19:02:35 hf@deer.(none) +4 -0
Fix for bug #10337 (cast(NULL DECIMAL) crashes the server)
strings/decimal.c
1.53 05/06/15 19:01:35 hf@deer.(none) +7 -1
we need to return specified 'scale' for the rounded decimal
sql/item_func.cc
1.220 05/06/15 19:01:35 hf@deer.(none) +8 -1
checks for NULL added
mysql-test/t/cast.test
1.20 05/06/15 19:01:35 hf@deer.(none) +6 -0
test case added
mysql-test/r/cast.result
1.30 05/06/15 19:01:35 hf@deer.(none) +3 -0
test result fixed
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: hf
# Host: deer.(none)
# Root: /home/hf/work/mysql-5.0.10337
--- 1.219/sql/item_func.cc Tue Jun 14 13:40:06 2005
+++ 1.220/sql/item_func.cc Wed Jun 15 19:01:35 2005
@@ -1022,7 +1022,8 @@
String *Item_decimal_typecast::val_str(String *str)
{
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);
return str;
}
@@ -1032,6 +1033,8 @@
{
my_decimal tmp_buf, *tmp= val_decimal(&tmp_buf);
double res;
+ if (null_value)
+ return 0.0;
my_decimal2double(E_DEC_FATAL_ERROR, tmp, &res);
return res;
}
@@ -1041,6 +1044,8 @@
{
my_decimal tmp_buf, *tmp= val_decimal(&tmp_buf);
longlong res;
+ if (null_value)
+ return 0;
my_decimal2int(E_DEC_FATAL_ERROR, tmp, unsigned_flag, &res);
return res;
}
@@ -1049,6 +1054,8 @@
my_decimal *Item_decimal_typecast::val_decimal(my_decimal *dec)
{
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);
return dec;
}
--- 1.29/mysql-test/r/cast.result Sat Apr 30 20:40:05 2005
+++ 1.30/mysql-test/r/cast.result Wed Jun 15 19:01:35 2005
@@ -344,3 +344,6 @@
cast(s1 as decimal(7,2))
111111.00
drop table t1;
+select cast(NULL as decimal(6)) as t1;
+t1
+NULL
--- 1.19/mysql-test/t/cast.test Sat Apr 30 11:46:04 2005
+++ 1.20/mysql-test/t/cast.test Wed Jun 15 19:01:35 2005
@@ -168,3 +168,9 @@
insert into t1 values ('11:11:11');
select cast(s1 as decimal(7,2)) from t1;
drop table t1;
+
+#
+# Bug @10237 (CAST(NULL DECIMAL) crashes server)
+#
+select cast(NULL as decimal(6)) as t1;
+
--- 1.52/strings/decimal.c Thu Jun 9 12:42:55 2005
+++ 1.53/strings/decimal.c Wed Jun 15 19:01:35 2005
@@ -1563,7 +1563,13 @@
break;
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;
}
}
| Thread |
|---|
| • bk commit into 5.0 tree (hf:1.1943) BUG#10337 | holyfoot | 15 Jun |