1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

MDEV-8102 REGEXP function fails to match hex values when expression is stored as a variable

We don't fix the bug itself, we just make regex functions display errors
returned from pcre_exec() as MariaDB warnings.
This commit is contained in:
Alexander Barkov
2015-05-14 14:43:37 +04:00
parent 0b4231e9f1
commit 46199c0e1d
6 changed files with 134 additions and 4 deletions

View File

@@ -845,3 +845,32 @@ SET default_regex_flags=DEFAULT;
SET default_regex_flags=DEFAULT;
#
# MDEV-6965 non-captured group \2 in regexp_replace
#
SELECT REGEXP_REPLACE('1 foo and bar', '(\\d+) foo and (\\d+ )?bar', '\\1 this and \\2that');
REGEXP_REPLACE('1 foo and bar', '(\\d+) foo and (\\d+ )?bar', '\\1 this and \\2that')
1 this and that
#
# MDEV-8102 REGEXP function fails to match hex values when expression is stored as a variable
#
# Testing a warning
SET NAMES latin1;
SET @regCheck= '\\xE0\\x01';
SELECT 0xE001 REGEXP @regCheck;
0xE001 REGEXP @regCheck
0
Warnings:
Warning 1139 Got error 'pcre_exec: Invalid utf8 byte sequence in the subject string' from regexp
# Testing workaround N1: This makes the pattern to be a binary string:
SET NAMES latin1;
SET @regCheck= X'E001';
SELECT 0xE001 REGEXP @regCheck;
0xE001 REGEXP @regCheck
1
# Testing workaround N2: This also makes the pattern to be a binary string, using a different syntax:
SET NAMES latin1;
SET @regCheck= _binary '\\xE0\\x01';
SELECT 0xE001 REGEXP @regCheck;
0xE001 REGEXP @regCheck
1
# Testing workarond N3: This makes derivation of the subject string stronger (IMLICIT instead of COERCIBLE)
SET NAMES latin1;