String Functions
TiDB supports most of the string functions available in MySQL 5.7, some of the string functions available in MySQL 8.0, and some of the functions available in Oracle 21.
For comparisons between functions and syntax of Oracle and TiDB, see Comparisons between Functions and Syntax of Oracle and TiDB.
Supported functions
Unsupported functions
LOAD_FILE()MATCH()SOUNDEX()
Regular expression compatibility with MySQL
The following sections describe the regular expression compatibility with MySQL.
Syntax compatibility
MySQL implements regular expression using International Components for Unicode (ICU), and TiDB uses RE2. To learn the syntax differences between the two libraries, you can refer to the ICU documentation and RE2 Syntax.
match_type compatibility
The value options of match_type between TiDB and MySQL are:
Value options in TiDB are
"c","i","m", and"s", and value options in MySQL are"c","i","m","n", and"u".The
"s"in TiDB corresponds to"n"in MySQL. When"s"is set in TiDB, the.character also matches line terminators (\n).For example, the
SELECT REGEXP_LIKE(a, b, "n") FROM t1in MySQL is the same as theSELECT REGEXP_LIKE(a, b, "s") FROM t1in TiDB.TiDB does not support
"u", which means Unix-only line endings in MySQL.
Data type compatibility
The difference between TiDB and MySQL support for the binary string type:
- MySQL does not support binary strings in regular expression functions since 8.0.22. For more details, refer to MySQL documentation. But in practice, regular functions can work in MySQL when all parameters or return types are binary strings. Otherwise, an error will be reported.
- Currently, TiDB prohibits using binary strings and an error will be reported under any circumstances.
Other compatibility
The difference between TiDB and MySQL support in replacing empty strings:
The following takes REGEXP_REPLACE("", "^$", "123") as an example:
- MySQL does not replace the empty string and returns
""as the result. - TiDB replaces the empty string and returns
"123"as the result.