--- a/sql/item_func.cc Mon Apr 9 14:36:22 2007 +++ b/sql/item_func2.cc Thu Apr 19 11:17:03 2007 @@ -2323,7 +2339,7 @@ void Item_func_locate::fix_length_and_dec() { - maybe_null= 0; + maybe_null= 1; max_length= MY_INT32_NUM_DECIMAL_DIGITS; agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV, 1); } --- a/mysql-test/t/func_str.test Sat Apr 7 12:23:31 2007 +++ b/mysql-test/t/func_str.test Thu Apr 19 11:29:25 2007 @@ -1059,3 +1059,14 @@ SELECT INSERT('abc', 6, 3, '1234'); --echo End of 5.0 tests + +# +#Bug#27932 locate does not compare against null +# + +select locate('foo', NULL); +select locate('foo', NULL) is null; + +create table t1 select locate('foo', NULL) as a; +desc t1; +drop table t1; --- a/mysql-test/r/func_str.result Sat Apr 7 12:23:31 2007 +++ b/mysql-test/r/func_str.result Thu Apr 19 11:29:33 2007 @@ -1993,3 +1993,14 @@ INSERT('abc', 6, 3, '1234') abc End of 5.0 tests +select locate('foo', NULL); +locate('foo', NULL) +NULL +select locate('foo', NULL) is null; +locate('foo', NULL) is null +1 +create table t1 select locate('foo', NULL) as a; +desc t1; +Field Type Null Key Default Extra +a int(11) YES NULL +drop table t1;