mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
If InnoDB FULLTEXT is available, use it for for fulltext indexes
Summary: Ref T11741. I'll wait until the release cut to land this; it just adds a test for InnoDB FULLTEXT being available instead of always returning `false`. Test Plan: - Ran with InnoDB fulltext locally for a day and a half without issues. - Ran `bin/storage upgrade`, saw it detect InnoDB fulltext. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11741 Differential Revision: https://secure.phabricator.com/D16946
This commit is contained in:
parent
2b7ec1deea
commit
d54c14c644
1 changed files with 22 additions and 5 deletions
|
@ -40,15 +40,15 @@ final class PhabricatorSearchDocument extends PhabricatorSearchDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function newQueryCompiler() {
|
public static function newQueryCompiler() {
|
||||||
$table = new self();
|
|
||||||
$conn = $table->establishConnection('r');
|
|
||||||
|
|
||||||
$compiler = new PhutilSearchQueryCompiler();
|
$compiler = new PhutilSearchQueryCompiler();
|
||||||
|
|
||||||
if (self::isInnoDBFulltextEngineAvailable()) {
|
if (self::isInnoDBFulltextEngineAvailable()) {
|
||||||
// The InnoDB fulltext boolean operators are always the same as the
|
// The InnoDB fulltext boolean operators are always the same as the
|
||||||
// default MyISAM operators, so we do not need to adjust the compiler.
|
// default MyISAM operators, so we do not need to adjust the compiler.
|
||||||
} else {
|
} else {
|
||||||
|
$table = new self();
|
||||||
|
$conn = $table->establishConnection('r');
|
||||||
|
|
||||||
$operators = queryfx_one(
|
$operators = queryfx_one(
|
||||||
$conn,
|
$conn,
|
||||||
'SELECT @@ft_boolean_syntax AS syntax');
|
'SELECT @@ft_boolean_syntax AS syntax');
|
||||||
|
@ -61,8 +61,25 @@ final class PhabricatorSearchDocument extends PhabricatorSearchDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isInnoDBFulltextEngineAvailable() {
|
public static function isInnoDBFulltextEngineAvailable() {
|
||||||
// For now, never consider this engine to be available.
|
static $available;
|
||||||
return false;
|
|
||||||
|
if ($available === null) {
|
||||||
|
$table = new self();
|
||||||
|
$conn = $table->establishConnection('r');
|
||||||
|
|
||||||
|
// If this system variable exists, we can use InnoDB fulltext. If it
|
||||||
|
// does not, this query will throw and we're stuck with MyISAM.
|
||||||
|
try {
|
||||||
|
queryfx_one(
|
||||||
|
$conn,
|
||||||
|
'SELECT @@innodb_ft_max_token_size');
|
||||||
|
$available = true;
|
||||||
|
} catch (AphrontQueryException $x) {
|
||||||
|
$available = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $available;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue