Skip to content

Commit 9975e2c

Browse files
committed
Document known REGEXP differences from MySQL
List the differences that come from PCRE: ICU-only syntax, CRLF line breaks, ICU sets, and POSIX classes outside of sets. Also list the ones that come from SQLite: binary values that are valid UTF-8 match as text, and numbers convert to text in a different format.
1 parent dd0e1c7 commit 9975e2c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎packages/mysql-on-sqlite/src/sqlite/class-wp-sqlite-pdo-user-defined-functions.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,13 @@ private function regexp_check_match_type( $function_name, $match_type ) {
10551055
* only the former and errors on the latter.
10561056
* - ICU supports multi-code-point case folds such as "ß" matching "ss";
10571057
* PCRE's case-insensitive mode does not.
1058+
* - ICU-only syntax, such as `\uXXXX` and `\N{name}` in patterns, is an error.
1059+
* - ICU reads CRLF as one line break, and PCRE as two characters. `$` also
1060+
* matches between them, and `.` with the `n` flag matches only one of them.
1061+
* - ICU's nested sets and set operations don't exist in PCRE. `[a[b]]` and
1062+
* `[a&&b]` silently match something else, and `[a--b]` is usually an error.
1063+
* - A POSIX class outside of a set, as in `[:alpha:]`, is usually an error. ICU
1064+
* reads it like `[[:alpha:]]`.
10581065
*
10591066
* Known limitations of this emulation:
10601067
*
@@ -1065,6 +1072,11 @@ private function regexp_check_match_type( $function_name, $match_type ) {
10651072
* - The `u` (UTF-8) PCRE modifier is applied to REGEXP_LIKE(), so it
10661073
* rejects data that is not valid UTF-8. The REGEXP operators match such
10671074
* data, and REGEXP BINARY, byte by byte, like MySQL binary strings.
1075+
* Binary values that are valid UTF-8 match as text, so case sensitivity
1076+
* can differ between rows.
1077+
* - SQLite converts float and decimal operands to text, in a different format
1078+
* from MySQL: `20e0` reads "20.0" (MySQL: "20"), `0.000001` reads "1.0e-06",
1079+
* and `1.50` reads "1.5". Integers above the BIGINT range read as floats.
10681080
*
10691081
* @param string $pattern The MySQL regex pattern.
10701082
* @param string $match_type MySQL match_type flag string.

0 commit comments

Comments
 (0)