Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Sources/Db/APIs/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ class MySQL extends DatabaseApi implements DatabaseApiInterface
*/
public bool $regex_tcl = true;

/**
*
*/
public bool $regex_posix = true;

/*********************
* Internal properties
*********************/
Expand Down Expand Up @@ -2620,12 +2625,8 @@ protected function initialize(array $options = []): void

if ($this->get_vendor() === 'MariaDB') {
$this->regex_pcre = version_compare(preg_replace('/^(\d+(?:\.\d+)+).*/', '$1', $this->get_version()), '10.0.5', '>=');

$this->regex_tcl = !$this->regex_pcre;
} else {
$this->regex_icu = version_compare(preg_replace('/^(\d+(?:\.\d+)+).*/', '$1', $this->get_version()), '8.0.4', '>=');

$this->regex_tcl = !$this->regex_icu;
}

$this->character_set = strtolower($this->detect_charset('messages', 'body'));
Expand Down
5 changes: 5 additions & 0 deletions Sources/Db/APIs/PostgreSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class PostgreSQL extends DatabaseApi implements DatabaseApiInterface
*/
public bool $regex_tcl = true;

/**
*
*/
public bool $regex_posix = true;

/*********************
* Internal properties
*********************/
Expand Down
7 changes: 7 additions & 0 deletions Sources/Db/DatabaseApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ abstract class DatabaseApi
*/
public bool $regex_tcl;

/**
* @var bool
*
* Whether the database supports POSIX regular expressions.
*/
public bool $regex_posix;

/**
* @var string
*
Expand Down
5 changes: 5 additions & 0 deletions Sources/Search/SearchApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,11 @@ protected function wordBoundaryWrapper(string $str): string
return \sprintf('\\y%s\\y', $str);
}

// POSIX uses `[[:<:]]` and `[[:>:]]` as the word boundaries.
if (Db::$db->regex_posix) {
return \sprintf('[[:<:]]%s[[:>:]]', $str);
}

// We should never get here, but just in case...
return $str;
}
Expand Down