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.2034 05/10/11 23:06:22 hf@deer.(none) +4 -0
Fix for bug #13573 (big DECIMAL values handled badly)
sql/item.cc
1.188 05/10/11 23:05:08 hf@deer.(none) +10 -2
handling overflow added to the constructors of Item_newdecimal
sql/field.cc
1.284 05/10/11 23:05:08 hf@deer.(none) +0 -11
this code is obsolete as far as i see
mysql-test/t/type_newdecimal.test
1.30 05/10/11 23:05:08 hf@deer.(none) +16 -0
test case added
mysql-test/r/type_newdecimal.result
1.32 05/10/11 23:05:08 hf@deer.(none) +27 -3
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.13573
--- 1.283/sql/field.cc Fri Sep 23 23:28:48 2005
+++ 1.284/sql/field.cc Tue Oct 11 23:05:08 2005
@@ -2457,17 +2457,6 @@
err= double2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW, nr,
&decimal_value);
- /*
- TODO: fix following when double2my_decimal when double2decimal
- will return E_DEC_TRUNCATED always correctly
- */
- if (!err)
- {
- double nr2;
- my_decimal2double(E_DEC_FATAL_ERROR, &decimal_value, &nr2);
- if (nr2 != nr)
- err= E_DEC_TRUNCATED;
- }
if (err)
{
if (check_overflow(err))
--- 1.187/sql/item.cc Tue Oct 11 14:58:20 2005
+++ 1.188/sql/item.cc Tue Oct 11 23:05:08 2005
@@ -1801,7 +1801,11 @@
Item_decimal::Item_decimal(const char *str_arg, uint length,
CHARSET_INFO *charset)
{
- str2my_decimal(E_DEC_FATAL_ERROR, str_arg, length, charset, &decimal_value);
+ if (str2my_decimal(E_DEC_FATAL_ERROR,
+ str_arg, length, charset, &decimal_value) == E_DEC_OVERFLOW)
+ {
+ max_my_decimal(&decimal_value, DECIMAL_MAX_PRECISION, 0);
+ }
name= (char*) str_arg;
decimals= (uint8) decimal_value.frac;
fixed= 1;
@@ -1823,7 +1827,11 @@
Item_decimal::Item_decimal(double val, int precision, int scale)
{
- double2my_decimal(E_DEC_FATAL_ERROR, val, &decimal_value);
+ if (double2my_decimal(E_DEC_FATAL_ERROR, val, &decimal_value) ==
+ E_DEC_OVERFLOW)
+ {
+ max_my_decimal(&decimal_value, DECIMAL_MAX_PRECISION, 0);
+ }
decimals= (uint8) decimal_value.frac;
fixed= 1;
unsigned_flag= !decimal_value.sign();
--- 1.31/mysql-test/r/type_newdecimal.result Fri Sep 30 15:01:26 2005
+++ 1.32/mysql-test/r/type_newdecimal.result Tue Oct 11 23:05:08 2005
@@ -846,15 +846,14 @@
NULL
select
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
as x;
x
-999999999999999999999999999999999999999999999999999999999999999999999999999999999
+99999999999999999999999999999999999999999999999999999999999999999
Warnings:
Error 1292 Truncated incorrect DECIMAL value: ''
select
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
+ 1 as x;
x
-NULL
+100000000000000000000000000000000000000000000000000000000000000000
Warnings:
Error 1292 Truncated incorrect DECIMAL value: ''
-Error 1292 Truncated incorrect DECIMAL value: ''
select 0.190287977636363637 + 0.040372670 * 0 - 0;
0.190287977636363637 + 0.040372670 * 0 - 0
0.190287977636363637
@@ -1019,3 +1018,28 @@
select cast(@non_existing_user_var/2 as DECIMAL);
cast(@non_existing_user_var/2 as DECIMAL)
NULL
+create table t1 (c1 decimal(64));
+insert into t1 values(
+89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
+Warnings:
+Error 1292 Truncated incorrect DECIMAL value: ''
+Warning 1264 Out of range value adjusted for column 'c1' at row 1
+insert into t1 values(
+65123456789012345678901234567890123456789012345678901234567890000);
+Warnings:
+Warning 1264 Out of range value adjusted for column 'c1' at row 1
+insert into t1 values(6.4123456E63);
+insert into t1 values(6.4123456E70);
+Warnings:
+Warning 1264 Out of range value adjusted for column 'c1' at row 1
+insert into t1 values(-6.4123456E70);
+Warnings:
+Warning 1264 Out of range value adjusted for column 'c1' at row 1
+select * from t1;
+c1
+9999999999999999999999999999999999999999999999999999999999999999
+9999999999999999999999999999999999999999999999999999999999999999
+6412345600000000899492411331745085252813067451936489276033728512
+9999999999999999999999999999999999999999999999999999999999999999
+-9999999999999999999999999999999999999999999999999999999999999999
+drop table t1;
--- 1.29/mysql-test/t/type_newdecimal.test Wed Sep 14 08:25:21 2005
+++ 1.30/mysql-test/t/type_newdecimal.test Tue Oct 11 23:05:08 2005
@@ -1044,3 +1044,19 @@
#
select cast(@non_existing_user_var/2 as DECIMAL);
+
+#
+# Bug #13573 (big DECIMAL values treatet incorrectly)
+#
+
+create table t1 (c1 decimal(64));
+insert into t1 values(
+89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
+insert into t1 values(
+65123456789012345678901234567890123456789012345678901234567890000);
+insert into t1 values(6.4123456E63);
+insert into t1 values(6.4123456E70);
+insert into t1 values(-6.4123456E70);
+select * from t1;
+drop table t1;
+
| Thread |
|---|
| • bk commit into 5.0 tree (hf:1.2034) BUG#13573 | holyfoot | 11 Oct |