Below is the list of changes that have just been committed into a local
5.0 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
1.2213 06/07/05 18:38:03 gluh@stripped +8 -0
Bug#16172 DECIMAL data type processed incorrectly
issue an error in case of DECIMAL(M,N) if N > M
issue an 'overflow warning' if result value is bigger than max possible value
sql/sql_yacc.yy
1.474 06/07/05 18:36:30 gluh@stripped +4 -0
Bug#16172 DECIMAL data type processed incorrectly
issue an error in case of DECIMAL(M,N) if N > M
sql/item_func.h
1.142 06/07/05 18:36:30 gluh@stripped +2 -0
Bug#16172 DECIMAL data type processed incorrectly
added max possible value
sql/item_func.cc
1.293 06/07/05 18:36:30 gluh@stripped +27 -0
Bug#16172 DECIMAL data type processed incorrectly
issue an 'overflow warning' if result value is bigger than max possible value
sql/item_create.cc
1.60 06/07/05 18:36:30 gluh@stripped +8 -1
Bug#16172 DECIMAL data type processed incorrectly
issue an error in case of DECIMAL(M,N) if N > M
do not increase decimal part on 2(according to manual)
mysql-test/t/type_newdecimal.test
1.38 06/07/05 18:36:30 gluh@stripped +18 -1
Bug#16172 DECIMAL data type processed incorrectly
test case & fix
mysql-test/r/view.result
1.163 06/07/05 18:36:29 gluh@stripped +1 -1
Bug#16172 DECIMAL data type processed incorrectly
result fix
mysql-test/r/type_newdecimal.result
1.41 06/07/05 18:36:29 gluh@stripped +31 -1
Bug#16172 DECIMAL data type processed incorrectly
result fix & test case
mysql-test/r/cast.result
1.46 06/07/05 18:36:29 gluh@stripped +5 -3
Bug#16172 DECIMAL data type processed incorrectly
result fix
# 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: eagle.intranet.mysql.r18.ru
# Root: /home/gluh/MySQL/Bugs/5.0.16172
--- 1.59/sql/item_create.cc Wed Apr 12 20:30:51 2006
+++ 1.60/sql/item_create.cc Wed Jul 5 18:36:30 2006
@@ -457,6 +457,7 @@ Item *create_func_cast(Item *a, Cast_tar
{
Item *res;
LINT_INIT(res);
+ int tmp_len;
switch (cast_type) {
case ITEM_CAST_BINARY: res= new Item_func_binary(a); break;
@@ -466,7 +467,13 @@ Item *create_func_cast(Item *a, Cast_tar
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);
+ tmp_len= (len>0) ? len : 10;
+ if (tmp_len < dec)
+ {
+ my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
+ return 0;
+ }
+ res= new Item_decimal_typecast(a, tmp_len, dec);
break;
case ITEM_CAST_CHAR:
res= new Item_char_typecast(a, len, cs ? cs :
--- 1.292/sql/item_func.cc Fri Jun 30 12:26:32 2006
+++ 1.293/sql/item_func.cc Wed Jul 5 18:36:30 2006
@@ -951,9 +951,36 @@ longlong Item_decimal_typecast::val_int(
my_decimal *Item_decimal_typecast::val_decimal(my_decimal *dec)
{
my_decimal tmp_buf, *tmp= args[0]->val_decimal(&tmp_buf);
+ int res;
+
if ((null_value= args[0]->null_value))
return NULL;
+
my_decimal_round(E_DEC_FATAL_ERROR, tmp, decimals, FALSE, dec);
+
+ if (dec->sign())
+ {
+ dec->sign(FALSE);
+ res= my_decimal_cmp(&max_val, dec);
+ dec->sign(TRUE);
+ }
+ else
+ res= my_decimal_cmp(&max_val, dec);
+ if (res == -1)
+ {
+ max_my_decimal(dec, max_length - 2, decimals);
+ if (tmp->sign())
+ {
+ if (unsigned_flag)
+ my_decimal_set_zero(dec);
+ else
+ dec->sign(TRUE);
+ }
+ 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.141/sql/item_func.h Fri Jun 30 12:26:32 2006
+++ 1.142/sql/item_func.h Wed Jul 5 18:36:30 2006
@@ -328,11 +328,13 @@ public:
class Item_decimal_typecast :public Item_func
{
my_decimal decimal_value;
+ my_decimal max_val;
public:
Item_decimal_typecast(Item *a, int len, int dec) :Item_func(a)
{
max_length= len + 2;
decimals= dec;
+ max_my_decimal(&max_val, len, decimals);
}
String *val_str(String *str);
double val_real();
--- 1.473/sql/sql_yacc.yy Mon Jul 3 13:19:08 2006
+++ 1.474/sql/sql_yacc.yy Wed Jul 5 18:36:30 2006
@@ -4344,6 +4344,8 @@ simple_expr:
lex->length ? atoi(lex->length) : -1,
lex->dec ? atoi(lex->dec) : 0,
lex->charset);
+ if (!$$)
+ YYABORT;
}
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
{ $$= new Item_func_case(* $4, $2, $5 ); }
@@ -4353,6 +4355,8 @@ simple_expr:
Lex->length ? atoi(Lex->length) : -1,
Lex->dec ? atoi(Lex->dec) : 0,
Lex->charset);
+ if (!$$)
+ YYABORT;
}
| CONVERT_SYM '(' expr USING charset_name ')'
{ $$= new Item_func_conv_charset($3,$5); }
--- 1.162/mysql-test/r/view.result Tue Jun 27 22:28:25 2006
+++ 1.163/mysql-test/r/view.result Wed Jul 5 18:36:29 2006
@@ -1787,7 +1787,7 @@ drop table t1;
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.40/mysql-test/r/type_newdecimal.result Thu Jun 15 16:23:56 2006
+++ 1.41/mysql-test/r/type_newdecimal.result Wed Jul 5 18:36:29 2006
@@ -915,9 +915,13 @@ drop table t1;
select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15));
cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15))
0.000000000100000
-select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;
+select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3;
c1 c2 c3
9.5468126085974 9.547 9.547
+select convert(ln(14000),decimal(2,3)) c1;
+ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
+select cast(ln(14000) as decimal(2,3)) c1;
+ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
create table t1 (sl decimal(70,30));
ERROR 42000: Too big precision 70 specified for column 'sl'. Maximum is 65.
create table t1 (sl decimal(32,31));
@@ -1408,3 +1412,29 @@ i2 count(distinct j)
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 adjusted 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 adjusted 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 adjusted for column 'cast(-13.4 as decimal(2,1))' at row 1
+select cast(-13.4 as decimal(1,2));
+ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
--- 1.37/mysql-test/t/type_newdecimal.test Thu Jun 15 16:23:56 2006
+++ 1.38/mysql-test/t/type_newdecimal.test Wed Jul 5 18:36:30 2006
@@ -947,7 +947,12 @@ select cast('1.0000000133514319600180897
#
# Bug #11708 (conversion to decimal fails in decimal part)
#
-select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;
+select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3;
+--error 1427
+select convert(ln(14000),decimal(2,3)) c1;
+--error 1427
+select cast(ln(14000) as decimal(2,3)) c1;
+
#
# Bug #8449 (Silent column changes)
@@ -1104,3 +1109,15 @@ insert into t1 values (1,1), (1,2), (2,3
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));
+--error 1427
+select cast(-13.4 as decimal(1,2));
--- 1.45/mysql-test/r/cast.result Sat Jun 17 02:57:23 2006
+++ 1.46/mysql-test/r/cast.result Wed Jul 5 18:36:29 2006
@@ -103,7 +103,7 @@ Warnings:
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 @@ create table t1(s1 time);
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 adjusted 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 @@ INSERT INTO t1 VALUES ('1.01', '2.02', '
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
| Thread |
|---|
| • bk commit into 5.0 tree (gluh:1.2213) BUG#16172 | gluh | 5 Jul |