Bug #70470 REGEXP fails to find matches after NUL character
Submitted: 30 Sep 2013 15:24 Modified: 13 Apr 2018 15:22
Reporter: Jesús Pérez Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.1.72,5.6.14,5.5.34,5.7.2 OS:Any
Assigned to: CPU Architecture:Any
Tags: nul, REGEXP, regular expressions

[30 Sep 2013 15:24] Jesús Pérez
Description:
MySQL fails to find matches with REGEXP after a NUL character.

Maybe related to bug #68153.

How to repeat:
This returns 1, as expected:

SELECT 'abc\0def' REGEXP 'abc';

But this will return 0 when it should return 1:

SELECT 'abc\0def' REGEXP 'def';

Also note that the same query with LIKE returns 1 as expected:

SELECT 'abc\0def' LIKE '%def%';

Tested with live sources from bzr (currently 5.7.2) and 5.5.32 so I guess that almost all branches are affected.
[1 Oct 2013 9:40] MySQL Verification Team
Hello Jesús,

Thank you for the bug report.
Verified as described.

Thanks,
Umesh
[2 Jun 2017 16:44] Oleg Smirnov
Looks like the same issue as https://bugs.mysql.com/bug.php?id=85588, so I guess suggested patch should fix this case too.
[13 Apr 2018 15:22] Paul DuBois
Posted by developer:
 
Fixed in 8.0.4.

REGEXP failed to find matches occurring after a \0 character in the
string expression.