From: Date: December 12 2008 3:28pm Subject: bzr push into mysql-5.1-bugteam branch (gshchepa:2737 to 2738) List-Archive: http://lists.mysql.com/commits/61506 Message-Id: <20081212143353.B859840C2D2@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT 2738 Gleb Shchepa 2008-12-12 [merge] auto merge 5.0-bugteam --> 5.1-bugteam (bug 40761) modified: mysql-test/r/func_if.result mysql-test/t/func_if.test sql/item_func.h 2737 Gleb Shchepa 2008-12-12 [merge] rollback of bug #40761 fix modified: mysql-test/r/func_if.result mysql-test/t/func_if.test sql/item_cmpfunc.cc sql/item_cmpfunc.h sql/item_func.cc sql/item_func.h === modified file 'mysql-test/r/func_if.result' --- a/mysql-test/r/func_if.result 2008-12-12 11:13:11 +0000 +++ b/mysql-test/r/func_if.result 2008-12-12 14:19:33 +0000 @@ -176,4 +176,13 @@ IF((ROUND(t1.a,2)=1), 2, IF((ROUND(t1.a,2)=1), 2, IF((R DROP TABLE t1; +CREATE TABLE t1 (c LONGTEXT); +INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890'); +SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +MAX(IF(1, CAST(c AS UNSIGNED), 0)) +12345678901234567890 +SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +MAX(IFNULL(CAST(c AS UNSIGNED), 0)) +12345678901234567890 +DROP TABLE t1; End of 5.0 tests === modified file 'mysql-test/t/func_if.test' --- a/mysql-test/t/func_if.test 2008-12-12 10:59:10 +0000 +++ b/mysql-test/t/func_if.test 2008-12-12 13:16:25 +0000 @@ -150,4 +150,18 @@ FROM t1; DROP TABLE t1; +# +# Bug #40761: Assert on sum func on IF(..., CAST(longtext AS UNSIGNED), signed) +# (was: LEFT JOIN on inline view crashes server) +# + +CREATE TABLE t1 (c LONGTEXT); +INSERT INTO t1 VALUES(1), (2), (3), (4), ('12345678901234567890'); + +SELECT * FROM (SELECT MAX(IF(1, CAST(c AS UNSIGNED), 0)) FROM t1) AS te; +SELECT * FROM (SELECT MAX(IFNULL(CAST(c AS UNSIGNED), 0)) FROM t1) AS te; + +DROP TABLE t1; + + --echo End of 5.0 tests === modified file 'sql/item_func.h' --- a/sql/item_func.h 2008-12-12 11:13:11 +0000 +++ b/sql/item_func.h 2008-12-12 14:19:33 +0000 @@ -362,7 +362,10 @@ public: Item_func_unsigned(Item *a) :Item_func_signed(a) {} const char *func_name() const { return "cast_as_unsigned"; } void fix_length_and_dec() - { max_length=args[0]->max_length; unsigned_flag=1; } + { + max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2); + unsigned_flag=1; + } longlong val_int(); virtual void print(String *str, enum_query_type query_type); };