diff options
-rw-r--r-- | mysql-test/r/func_str.result | 7 | ||||
-rw-r--r-- | mysql-test/t/func_str.test | 9 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 9 |
3 files changed, 24 insertions, 1 deletions
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 35a5ba70e86..7d2668c8cf6 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -266,3 +266,10 @@ CONCAT("</a>",RPAD("",(55 - LENGTH(title)),".")) NULL </a>.......................... DROP TABLE t1; +CREATE TABLE t1 (i int, j int); +INSERT INTO t1 VALUES (1,1),(2,2); +SELECT DISTINCT i, ELT(j, '345', '34') FROM t1; +i ELT(j, '345', '34') +1 345 +2 34 +DROP TABLE t1; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 33d89b3ca37..1eba49a9583 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -154,3 +154,12 @@ INSERT INTO t1 VALUES ('House passes the CAREERS bill'); SELECT CONCAT("</a>",RPAD("",(55 - LENGTH(title)),".")) from t1; DROP TABLE t1; + +# +# test for Bug #2290 "output truncated with ELT when using DISTINCT" +# + +CREATE TABLE t1 (i int, j int); +INSERT INTO t1 VALUES (1,1),(2,2); +SELECT DISTINCT i, ELT(j, '345', '34') FROM t1; +DROP TABLE t1; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index a4d04253dd7..74a7c97113e 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1507,7 +1507,14 @@ void Item_func_elt::fix_length_and_dec() { max_length=0; decimals=0; - for (uint i=1 ; i < arg_count ; i++) + /* + first numeric argument isn't in args (3.23 and 4.0) + but since 4.1 the cycle should start from 1 + so this change + + should NOT be merged into 4.1!!! + */ + for (uint i= 0; i < arg_count ; i++) { set_if_bigger(max_length,args[i]->max_length); set_if_bigger(decimals,args[i]->decimals); |