#At file:///home/hf/work/mysql_common/45780/ based on revid:v.narayanan@stripped
3007 Alexey Botchkov 2009-07-07
Bug#45780 CONCAT(CASE(numeric)) returns wrong length
it's more natural to calculate the precision of the result with the
functions like Item::decimal_precision() or Item::decimal_int_part()
than with the indirect methods from the max_length
per-file comments:
mysql-test/r/func_concat.result
Bug#45780 CONCAT(CASE(numeric)) returns wrong length
test result
mysql-test/t/func_concat.test
Bug#45780 CONCAT(CASE(numeric)) returns wrong length
test case
sql/item_cmpfunc.cc
Bug#45780 CONCAT(CASE(numeric)) returns wrong length
use Item::decimal_int_part() to calculate the precision of the result
modified:
mysql-test/r/func_concat.result
mysql-test/t/func_concat.test
sql/item_cmpfunc.cc
=== modified file 'mysql-test/r/func_concat.result'
--- a/mysql-test/r/func_concat.result 2009-05-21 08:06:43 +0000
+++ b/mysql-test/r/func_concat.result 2009-07-07 13:51:31 +0000
@@ -119,4 +119,11 @@ id select_type table type possible_keys
1 SIMPLE t2 index NULL PRIMARY 102 NULL 3 Using index
1 SIMPLE t1 eq_ref PRIMARY,a PRIMARY 318 func,const,const 1
DROP TABLE t1, t2;
+CREATE TABLE t1 AS SELECT CONCAT(CASE WHEN 1 THEN 2 ELSE 3 END) AS c1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` varbinary(2) NOT NULL DEFAULT ''
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
# End of 5.1 tests
=== modified file 'mysql-test/t/func_concat.test'
--- a/mysql-test/t/func_concat.test 2009-05-21 08:06:43 +0000
+++ b/mysql-test/t/func_concat.test 2009-07-07 13:51:31 +0000
@@ -111,4 +111,7 @@ EXPLAIN SELECT CONCAT('gui_', t2.a), t1.
DROP TABLE t1, t2;
+CREATE TABLE t1 AS SELECT CONCAT(CASE WHEN 1 THEN 2 ELSE 3 END) AS c1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
--echo # End of 5.1 tests
=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc 2009-07-03 10:36:04 +0000
+++ b/sql/item_cmpfunc.cc 2009-07-07 13:51:31 +0000
@@ -2676,9 +2676,7 @@ void Item_func_case::agg_str_lengths(Ite
void Item_func_case::agg_num_lengths(Item *arg)
{
- uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals,
- arg->unsigned_flag) - arg->decimals;
- set_if_bigger(max_length, len);
+ set_if_bigger(max_length, arg->decimal_int_part());
set_if_bigger(decimals, arg->decimals);
unsigned_flag= unsigned_flag && arg->unsigned_flag;
}
Attachment: [text/bzr-bundle] bzr/holyfoot@mysql.com-20090707135131-rizy5nkd4qp32rr0.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (holyfoot:3007) Bug#45780 | Alexey Botchkov | 7 Jul |