From: Date: November 16 2006 11:21am Subject: bk commit into 4.1 tree (kroki:1.2540) BUG#17047 List-Archive: http://lists.mysql.com/commits/15399 X-Bug: 17047 Message-Id: <200611161021.kAGALiXt024828@moonlight.intranet> Below is the list of changes that have just been committed into a local 4.1 repository of tomash. When tomash 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, 2006-11-16 13:21:38+03:00, kroki@stripped +3 -0 BUG#17047: CHAR() and IN() can return NULL without signaling NULL result The problem was that some functions (namely IN() starting with 4.1, and CHAR() starting with 5.0) were returning NULL in certain conditions, while they didn't set their maybe_null flag. Because of that there could be some problems with 'IS NULL' check, and statements that depend on the function value domain, like CREATE TABLE t1 SELECT 1 IN (2, NULL);. The fix is to set maybe_null correctly. mysql-test/r/func_in.result@stripped, 2006-11-16 13:21:36+03:00, kroki@stripped +8 -0 Add result for bug#17047: CHAR() and IN() can return NULL without signaling NULL result. mysql-test/t/func_in.test@stripped, 2006-11-16 13:21:36+03:00, kroki@stripped +21 -1 Add test case for bug#17047: CHAR() and IN() can return NULL without signaling NULL result. sql/item_cmpfunc.cc@stripped, 2006-11-16 13:21:36+03:00, kroki@stripped +0 -1 Remove assignment to maybe_null, as it was already set in fix_fields() based on all arguments, not only on the first. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: kroki # Host: moonlight.intranet # Root: /home/tomash/src/mysql_ab/mysql-4.1-bug17047 --- 1.216/sql/item_cmpfunc.cc 2006-11-16 13:21:45 +03:00 +++ 1.217/sql/item_cmpfunc.cc 2006-11-16 13:21:45 +03:00 @@ -1998,7 +1998,6 @@ void Item_func_in::fix_length_and_dec() if (cmp_type == STRING_RESULT) in_item->cmp_charset= cmp_collation.collation; } - maybe_null= args[0]->maybe_null; max_length= 1; } --- 1.18/mysql-test/r/func_in.result 2006-11-16 13:21:45 +03:00 +++ 1.19/mysql-test/r/func_in.result 2006-11-16 13:21:45 +03:00 @@ -202,3 +202,11 @@ select count(*) from t1 where id not in count(*) 1 drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 SELECT 1 IN (2, NULL); +SELECT should return NULL. +SELECT * FROM t1; +1 IN (2, NULL) +NULL +DROP TABLE t1; +End of 4.1 tests --- 1.18/mysql-test/t/func_in.test 2006-11-16 13:21:45 +03:00 +++ 1.19/mysql-test/t/func_in.test 2006-11-16 13:21:45 +03:00 @@ -109,4 +109,24 @@ select count(*) from t1 where id not in select count(*) from t1 where id not in (1,2); drop table t1; -# End of 4.1 tests + +# +# BUG#17047: CHAR() and IN() can return NULL without signaling NULL +# result +# +# The problem was in the IN() function that ignored maybe_null flags +# of all arguments except the first (the one _before_ the IN +# keyword, '1' in the test case below). +# +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 SELECT 1 IN (2, NULL); +--echo SELECT should return NULL. +SELECT * FROM t1; + +DROP TABLE t1; + + +--echo End of 4.1 tests