From: Tor Didriksen Date: January 14 2011 3:37pm Subject: bzr push into mysql-5.5 branch (tor.didriksen:3248 to 3249) Bug#59498 List-Archive: http://lists.mysql.com/commits/128815 X-Bug: 59498 Message-Id: <20110114153738.D36393784@atum07.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3249 Tor Didriksen 2011-01-14 Bug #59498 div function broken in mysql-trunk @ mysql-test/r/func_math.result New test case. @ mysql-test/t/func_math.test New test case. @ sql/item_func.cc Check for null before converting value to my_decimal. modified: mysql-test/r/func_math.result mysql-test/t/func_math.test sql/item_func.cc 3248 Nirbhay Choubey 2011-01-14 [merge] Merging fix of Bug#13618 from mysql-5.1. modified: client/mysqldump.c mysql-test/r/client_xml.result mysql-test/r/mysqldump.result mysql-test/t/mysqldump.test === modified file 'mysql-test/r/func_math.result' --- a/mysql-test/r/func_math.result 2011-01-14 09:05:14 +0000 +++ b/mysql-test/r/func_math.result 2011-01-14 14:03:37 +0000 @@ -650,3 +650,9 @@ SELECT ((@a:=@b:=1.0) div (@b:=@a:=get_f NULL Warnings: Warning 1366 Incorrect decimal value: '' for column '' at row -1 +# +# Bug #59498 div function broken in mysql-trunk +# +SELECT 1 div null; +1 div null +NULL === modified file 'mysql-test/t/func_math.test' --- a/mysql-test/t/func_math.test 2011-01-14 09:05:14 +0000 +++ b/mysql-test/t/func_math.test 2011-01-14 14:03:37 +0000 @@ -495,3 +495,8 @@ DROP TABLE t1; --echo # in do_div_mod with doubly assigned variables --echo # SELECT ((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa'))); + +--echo # +--echo # Bug #59498 div function broken in mysql-trunk +--echo # +SELECT 1 div null; === modified file 'sql/item_func.cc' --- a/sql/item_func.cc 2011-01-14 09:05:14 +0000 +++ b/sql/item_func.cc 2011-01-14 14:03:37 +0000 @@ -1582,10 +1582,15 @@ longlong Item_func_int_div::val_int() args[1]->result_type() != INT_RESULT) { my_decimal tmp; - my_decimal val0= *args[0]->val_decimal(&tmp); - my_decimal val1= *args[1]->val_decimal(&tmp); - if ((null_value= (args[0]->null_value || args[1]->null_value))) + my_decimal *val0p= args[0]->val_decimal(&tmp); + if ((null_value= args[0]->null_value)) return 0; + my_decimal val0= *val0p; + + my_decimal *val1p= args[1]->val_decimal(&tmp); + if ((null_value= args[1]->null_value)) + return 0; + my_decimal val1= *val1p; int err; if ((err= my_decimal_div(E_DEC_FATAL_ERROR & ~E_DEC_DIV_ZERO, &tmp, No bundle (reason: useless for push emails).