Below is the list of changes that have just been committed into a local
5.1 repository of gluh. When gluh 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@stripped, 2006-08-08 16:03:42+05:00, gluh@stripped +9 -0
Bug#16172 DECIMAL data type processed incorrectly
issue an 'overflow warning' if result value is bigger than max possible value
include/decimal.h@stripped, 2006-08-08 16:03:35+05:00, gluh@stripped +1 -0
Bug#16172 DECIMAL data type processed incorrectly
new function decimal_intg()
mysql-test/r/cast.result@stripped, 2006-08-08 16:03:35+05:00, gluh@stripped +5 -3
Bug#16172 DECIMAL data type processed incorrectly
result fix
mysql-test/r/type_newdecimal.result@stripped, 2006-08-08 16:03:35+05:00, gluh@stripped +27
-0
Bug#16172 DECIMAL data type processed incorrectly
test result
mysql-test/r/view.result@stripped, 2006-08-08 16:03:35+05:00, gluh@stripped +1 -1
Bug#16172 DECIMAL data type processed incorrectly
result fix
mysql-test/t/type_newdecimal.test@stripped, 2006-08-08 16:03:35+05:00, gluh@stripped +11 -0
Bug#16172 DECIMAL data type processed incorrectly
test case
sql/item_create.cc@stripped, 2006-08-08 16:03:35+05:00, gluh@stripped +1 -1
Bug#16172 DECIMAL data type processed incorrectly
do not increase decimal part on 2(according to manual)
sql/item_func.cc@stripped, 2006-08-08 16:03:35+05:00, gluh@stripped +23 -0
Bug#16172 DECIMAL data type processed incorrectly
issue an 'overflow warning' if result value is bigger than max possible value
sql/my_decimal.h@stripped, 2006-08-08 16:03:35+05:00, gluh@stripped +8 -0
Bug#16172 DECIMAL data type processed incorrectly
new function my_decimal_intg()
strings/decimal.c@stripped, 2006-08-08 16:03:35+05:00, gluh@stripped +8 -0
Bug#16172 DECIMAL data type processed incorrectly
new function decimal_intg()
# 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: gluh
# Host: gluh.(none)
# Root: /home/gluh/MySQL/Merge/5.1-kt
--- 1.64/sql/item_create.cc 2006-08-08 16:03:59 +05:00
+++ 1.65/sql/item_create.cc 2006-08-08 16:03:59 +05:00
@@ -463,7 +463,7 @@
case ITEM_CAST_TIME: res= new Item_time_typecast(a); break;
case ITEM_CAST_DATETIME: res= new Item_datetime_typecast(a); break;
case ITEM_CAST_DECIMAL:
- res= new Item_decimal_typecast(a, (len>0) ? len : 10, dec ? dec : 2);
+ res= new Item_decimal_typecast(a, (len > 0) ? len : 10, dec);
break;
case ITEM_CAST_CHAR:
res= new Item_char_typecast(a, len, cs ? cs :
--- 1.306/sql/item_func.cc 2006-08-08 16:03:59 +05:00
+++ 1.307/sql/item_func.cc 2006-08-08 16:03:59 +05:00
@@ -955,9 +955,32 @@
my_decimal *Item_decimal_typecast::val_decimal(my_decimal *dec)
{
my_decimal tmp_buf, *tmp= args[0]->val_decimal(&tmp_buf);
+ bool sign;
if ((null_value= args[0]->null_value))
return NULL;
my_decimal_round(E_DEC_FATAL_ERROR, tmp, decimals, FALSE, dec);
+ sign= dec->sign();
+ if (unsigned_flag)
+ {
+ if (sign)
+ {
+ my_decimal_set_zero(dec);
+ goto err;
+ }
+ }
+ if (max_length - 2 - decimals < (uint) my_decimal_intg(dec))
+ {
+ max_my_decimal(dec, max_length - 2, decimals);
+ dec->sign(sign);
+ goto err;
+ }
+ return dec;
+
+err:
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ ER_WARN_DATA_OUT_OF_RANGE,
+ ER(ER_WARN_DATA_OUT_OF_RANGE),
+ name, 1);
return dec;
}
--- 1.170/mysql-test/r/view.result 2006-08-08 16:03:59 +05:00
+++ 1.171/mysql-test/r/view.result 2006-08-08 16:03:59 +05:00
@@ -1787,7 +1787,7 @@
create view v1 as select cast(1 as decimal);
select * from v1;
cast(1 as decimal)
-1.00
+1
drop view v1;
create table t1(f1 int);
create table t2(f2 int);
--- 1.47/mysql-test/r/type_newdecimal.result 2006-08-08 16:03:59 +05:00
+++ 1.48/mysql-test/r/type_newdecimal.result 2006-08-08 16:03:59 +05:00
@@ -1418,3 +1418,30 @@
1.0 2
2.0 2
drop table t1;
+select cast(143.481 as decimal(4,1));
+cast(143.481 as decimal(4,1))
+143.5
+select cast(143.481 as decimal(4,0));
+cast(143.481 as decimal(4,0))
+143
+select cast(143.481 as decimal(2,1));
+cast(143.481 as decimal(2,1))
+9.9
+Warnings:
+Error 1264 Out of range value for column 'cast(143.481 as decimal(2,1))' at row 1
+select cast(-3.4 as decimal(2,1));
+cast(-3.4 as decimal(2,1))
+-3.4
+select cast(99.6 as decimal(2,0));
+cast(99.6 as decimal(2,0))
+99
+Warnings:
+Error 1264 Out of range value for column 'cast(99.6 as decimal(2,0))' at row 1
+select cast(-13.4 as decimal(2,1));
+cast(-13.4 as decimal(2,1))
+-9.9
+Warnings:
+Error 1264 Out of range value for column 'cast(-13.4 as decimal(2,1))' at row 1
+select cast(98.6 as decimal(2,0));
+cast(98.6 as decimal(2,0))
+99
--- 1.40/mysql-test/t/type_newdecimal.test 2006-08-08 16:03:59 +05:00
+++ 1.41/mysql-test/t/type_newdecimal.test 2006-08-08 16:03:59 +05:00
@@ -1115,3 +1115,14 @@
select i, count(distinct j) from t1 group by i;
select i+0.0 as i2, count(distinct j) from t1 group by i2;
drop table t1;
+
+#
+# Bug#16172 DECIMAL data type processed incorrectly
+#
+select cast(143.481 as decimal(4,1));
+select cast(143.481 as decimal(4,0));
+select cast(143.481 as decimal(2,1));
+select cast(-3.4 as decimal(2,1));
+select cast(99.6 as decimal(2,0));
+select cast(-13.4 as decimal(2,1));
+select cast(98.6 as decimal(2,0));
--- 1.10/sql/my_decimal.h 2006-08-08 16:03:59 +05:00
+++ 1.11/sql/my_decimal.h 2006-08-08 16:03:59 +05:00
@@ -383,5 +383,13 @@
return decimal_cmp((decimal_t*) a, (decimal_t*) b);
}
+
+inline
+int my_decimal_intg(const my_decimal *a)
+{
+ return decimal_intg((decimal_t*) a);
+}
+
+
#endif /*my_decimal_h*/
--- 1.44/mysql-test/r/cast.result 2006-08-08 16:03:59 +05:00
+++ 1.45/mysql-test/r/cast.result 2006-08-08 16:03:59 +05:00
@@ -103,7 +103,7 @@
Warning 1292 Truncated incorrect DOUBLE value: 'a'
select 10.0+cast('a' as decimal);
10.0+cast('a' as decimal)
-10.00
+10.0
Warnings:
Warning 1292 Truncated incorrect DECIMAL value: 'a'
select 10E+0+'a';
@@ -368,7 +368,9 @@
insert into t1 values ('11:11:11');
select cast(s1 as decimal(7,2)) from t1;
cast(s1 as decimal(7,2))
-111111.00
+99999.99
+Warnings:
+Error 1264 Out of range value for column 'cast(s1 as decimal(7,2))' at row 1
drop table t1;
CREATE TABLE t1 (v varchar(10), tt tinytext, t text,
mt mediumtext, lt longtext);
@@ -376,7 +378,7 @@
SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL),
CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1;
CAST(v AS DECIMAL) CAST(tt AS DECIMAL) CAST(t AS DECIMAL) CAST(mt AS DECIMAL) CAST(lt AS
DECIMAL)
-1.01 2.02 3.03 4.04 5.05
+1 2 3 4 5
DROP TABLE t1;
select cast(NULL as decimal(6)) as t1;
t1
--- 1.15/include/decimal.h 2006-08-08 16:03:59 +05:00
+++ 1.16/include/decimal.h 2006-08-08 16:03:59 +05:00
@@ -48,6 +48,7 @@
int decimal_result_size(decimal_t *from1, decimal_t *from2, char op,
int param);
+int decimal_intg(decimal_t *from);
int decimal_add(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_sub(decimal_t *from1, decimal_t *from2, decimal_t *to);
int decimal_cmp(decimal_t *from1, decimal_t *from2);
--- 1.72/strings/decimal.c 2006-08-08 16:04:00 +05:00
+++ 1.73/strings/decimal.c 2006-08-08 16:04:00 +05:00
@@ -1896,6 +1896,14 @@
return error;
}
+int decimal_intg(decimal_t *from)
+{
+ int res;
+ dec1 *tmp_res;
+ tmp_res= remove_leading_zeroes(from, &res);
+ return res;
+}
+
int decimal_add(decimal_t *from1, decimal_t *from2, decimal_t *to)
{
if (likely(from1->sign == from2->sign))
| Thread |
|---|
| • bk commit into 5.1 tree (gluh:1.2266) BUG#16172 | gluh | 8 Aug |