diff --git a/src/applications/config/check/PhabricatorMySQLSetupCheck.php b/src/applications/config/check/PhabricatorMySQLSetupCheck.php --- a/src/applications/config/check/PhabricatorMySQLSetupCheck.php +++ b/src/applications/config/check/PhabricatorMySQLSetupCheck.php @@ -121,8 +121,18 @@ ->addMySQLConfig('sql_mode'); } - $stopword_file = $ref->loadRawMySQLConfigValue('ft_stopword_file'); + $is_innodb_fulltext = false; + $is_myisam_fulltext = false; if ($this->shouldUseMySQLSearchEngine()) { + if (PhabricatorSearchDocument::isInnoDBFulltextEngineAvailable()) { + $is_innodb_fulltext = true; + } else { + $is_myisam_fulltext = true; + } + } + + if ($is_myisam_fulltext) { + $stopword_file = $ref->loadRawMySQLConfigValue('ft_stopword_file'); if ($stopword_file === null) { $summary = pht( 'Your version of MySQL (on database host "%s") does not support '. @@ -200,9 +210,9 @@ } } - $min_len = $ref->loadRawMySQLConfigValue('ft_min_word_len'); - if ($min_len >= 4) { - if ($this->shouldUseMySQLSearchEngine()) { + if ($is_myisam_fulltext) { + $min_len = $ref->loadRawMySQLConfigValue('ft_min_word_len'); + if ($min_len >= 4) { $namespace = PhabricatorEnv::getEnvConfig('storage.default-namespace'); $summary = pht( @@ -248,6 +258,18 @@ } } + // NOTE: The default value of "innodb_ft_min_token_size" is 3, which is + // a reasonable value, so we do not warn about it: if it is set to + // something else, the user adjusted it on their own. + + // NOTE: We populate a stopwords table at "phabricator_search.stopwords", + // but the default InnoDB stopword list is pretty reasonable (36 words, + // versus 500+ in MyISAM). Just use the builtin list until we run into + // concrete issues with it. Users can switch to our stopword table with: + // + // [mysqld] + // innodb_ft_server_stopword_table = phabricator_search/stopwords + $innodb_pool = $ref->loadRawMySQLConfigValue('innodb_buffer_pool_size'); $innodb_bytes = phutil_parse_bytes($innodb_pool); $innodb_readable = phutil_format_bytes($innodb_bytes); diff --git a/src/applications/config/schema/PhabricatorConfigSchemaSpec.php b/src/applications/config/schema/PhabricatorConfigSchemaSpec.php --- a/src/applications/config/schema/PhabricatorConfigSchemaSpec.php +++ b/src/applications/config/schema/PhabricatorConfigSchemaSpec.php @@ -63,7 +63,12 @@ $database = $this->getDatabase($database_name); $table = $this->newTable($table_name); - $fulltext_engine = 'MyISAM'; + + if (PhabricatorSearchDocument::isInnoDBFulltextEngineAvailable()) { + $fulltext_engine = 'InnoDB'; + } else { + $fulltext_engine = 'MyISAM'; + } foreach ($columns as $name => $type) { if ($type === null) { diff --git a/src/applications/search/storage/document/PhabricatorSearchDocument.php b/src/applications/search/storage/document/PhabricatorSearchDocument.php --- a/src/applications/search/storage/document/PhabricatorSearchDocument.php +++ b/src/applications/search/storage/document/PhabricatorSearchDocument.php @@ -45,14 +45,24 @@ $compiler = new PhutilSearchQueryCompiler(); - $operators = queryfx_one( - $conn, - 'SELECT @@ft_boolean_syntax AS syntax'); - if ($operators) { - $compiler->setOperators($operators['syntax']); + if (self::isInnoDBFulltextEngineAvailable()) { + // The InnoDB fulltext boolean operators are always the same as the + // default MyISAM operators, so we do not need to adjust the compiler. + } else { + $operators = queryfx_one( + $conn, + 'SELECT @@ft_boolean_syntax AS syntax'); + if ($operators) { + $compiler->setOperators($operators['syntax']); + } } return $compiler; } + public static function isInnoDBFulltextEngineAvailable() { + // For now, never consider this engine to be available. + return false; + } + }