From: Date: April 22 2008 12:53am Subject: bk commit into 5.0 tree (sergefp:1.2609) BUG#36139 List-Archive: http://lists.mysql.com/commits/45791 X-Bug: 36139 Message-Id: <20080421225318.A926622B187@pslp.localdomain> Below is the list of changes that have just been committed into a local 5.0 repository of sergefp. When sergefp 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, 2008-04-22 02:53:12+04:00, sergefp@stripped +3 -0 BUG#36139 "float, zerofill, crash with subquery" - Make convert_zerofill_number_to_string() take into account that the constant it is converting may evaluate to NULL. mysql-test/r/subselect.result@stripped, 2008-04-22 02:53:07+04:00, sergefp@stripped +7 -0 BUG#36139 "float, zerofill, crash with subquery" - Testcase mysql-test/t/subselect.test@stripped, 2008-04-22 02:53:07+04:00, sergefp@stripped +12 -0 BUG#36139 "float, zerofill, crash with subquery" - Testcase sql/item.cc@stripped, 2008-04-22 02:53:07+04:00, sergefp@stripped +8 -3 BUG#36139 "float, zerofill, crash with subquery" - Make convert_zerofill_number_to_string() take into account that the constant it is converting may evaluate to NULL. diff -Nrup a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result --- a/mysql-test/r/subselect.result 2008-02-20 17:40:52 +03:00 +++ b/mysql-test/r/subselect.result 2008-04-22 02:53:07 +04:00 @@ -4374,4 +4374,11 @@ a4 f3 a6 1 NULL NULL 2 NULL NULL DROP TABLE t1, t2, t3, t4; +create table t1 (a float(5,4) zerofill); +create table t2 (a float(5,4),b float(2,0)); +select t1.a from t1 where +t1.a= (select b from t2 limit 1) and not +t1.a= (select a from t2 limit 1) ; +a +drop table t1; End of 5.0 tests. diff -Nrup a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test --- a/mysql-test/t/subselect.test 2008-02-20 17:40:40 +03:00 +++ b/mysql-test/t/subselect.test 2008-04-22 02:53:07 +04:00 @@ -3259,5 +3259,17 @@ GROUP BY a4; DROP TABLE t1, t2, t3, t4; +# +# BUG#36139 "float, zerofill, crash with subquery" +# +create table t1 (a float(5,4) zerofill); +create table t2 (a float(5,4),b float(2,0)); + +select t1.a from t1 where + t1.a= (select b from t2 limit 1) and not + t1.a= (select a from t2 limit 1) ; + +drop table t1; + --echo End of 5.0 tests. diff -Nrup a/sql/item.cc b/sql/item.cc --- a/sql/item.cc 2008-03-28 14:31:48 +03:00 +++ b/sql/item.cc 2008-04-22 02:53:07 +04:00 @@ -4156,9 +4156,14 @@ static void convert_zerofill_number_to_s String tmp(buff,sizeof(buff), field->charset()), *res; res= (*item)->val_str(&tmp); - field->prepend_zeros(res); - pos= (char *) sql_strmake (res->ptr(), res->length()); - *item= new Item_string(pos, res->length(), field->charset()); + if ((*item)->is_null()) + *item= new Item_null(); + else + { + field->prepend_zeros(res); + pos= (char *) sql_strmake (res->ptr(), res->length()); + *item= new Item_string(pos, res->length(), field->charset()); + } }