Skip to content

Commit addb01f

Browse files
committed
MDEV-37740 LOCATE(X,Y,NULL) is not NULL
LOCATE is documented to return NULL if any of its arguments is NULL
1 parent 5738edf commit addb01f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

mysql-test/main/func_str.result

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5623,5 +5623,9 @@ DROP TABLE t2;
56235623
DROP TABLE t1;
56245624
SET sql_mode=DEFAULT;
56255625
#
5626-
# End of 10.11 tests
5626+
# MDEV-37740 LOCATE(X,Y,NULL) is not NULL
56275627
#
5628+
select locate(1,2,NULL);
5629+
locate(1,2,NULL)
5630+
NULL
5631+
# End of 10.11 tests

mysql-test/main/func_str.test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2573,5 +2573,8 @@ DROP TABLE t1;
25732573
SET sql_mode=DEFAULT;
25742574

25752575
--echo #
2576-
--echo # End of 10.11 tests
2576+
--echo # MDEV-37740 LOCATE(X,Y,NULL) is not NULL
25772577
--echo #
2578+
select locate(1,2,NULL);
2579+
2580+
--echo # End of 10.11 tests

sql/item_func.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,7 +3247,10 @@ longlong Item_func_locate::val_int()
32473247
start0= start= args[2]->val_int();
32483248

32493249
if ((start <= 0) || (start > a->length()))
3250+
{
3251+
null_value= args[2]->is_null();
32503252
return 0;
3253+
}
32513254
start0--; start--;
32523255

32533256
/* start is now sufficiently valid to pass to charpos function */

0 commit comments

Comments
 (0)