@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Prepare for InnoDB FULLTEXT support

Summary:
Ref T11741. This makes everything work if we switch to InnoDB, but never actually switches yet.

Since the default minimum word length (3) and stopword list (36 common English words) in InnoDB are generally pretty reasonable, I just didn't add any setup advice for them. I figure we're better off with simpler setup until we identify some real problem that the builtin stopwords create.

Test Plan: Swapped the `false` to `true`, ran `storage adjust`, got InnoDB fulltext indexes, searched for stuff, got default "AND" behavior.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11741

Differential Revision: https://secure.phabricator.com/D16942

+47 -10
+26 -4
src/applications/config/check/PhabricatorMySQLSetupCheck.php
··· 121 121 ->addMySQLConfig('sql_mode'); 122 122 } 123 123 124 - $stopword_file = $ref->loadRawMySQLConfigValue('ft_stopword_file'); 124 + $is_innodb_fulltext = false; 125 + $is_myisam_fulltext = false; 125 126 if ($this->shouldUseMySQLSearchEngine()) { 127 + if (PhabricatorSearchDocument::isInnoDBFulltextEngineAvailable()) { 128 + $is_innodb_fulltext = true; 129 + } else { 130 + $is_myisam_fulltext = true; 131 + } 132 + } 133 + 134 + if ($is_myisam_fulltext) { 135 + $stopword_file = $ref->loadRawMySQLConfigValue('ft_stopword_file'); 126 136 if ($stopword_file === null) { 127 137 $summary = pht( 128 138 'Your version of MySQL (on database host "%s") does not support '. ··· 200 210 } 201 211 } 202 212 203 - $min_len = $ref->loadRawMySQLConfigValue('ft_min_word_len'); 204 - if ($min_len >= 4) { 205 - if ($this->shouldUseMySQLSearchEngine()) { 213 + if ($is_myisam_fulltext) { 214 + $min_len = $ref->loadRawMySQLConfigValue('ft_min_word_len'); 215 + if ($min_len >= 4) { 206 216 $namespace = PhabricatorEnv::getEnvConfig('storage.default-namespace'); 207 217 208 218 $summary = pht( ··· 247 257 ->addMySQLConfig('ft_min_word_len'); 248 258 } 249 259 } 260 + 261 + // NOTE: The default value of "innodb_ft_min_token_size" is 3, which is 262 + // a reasonable value, so we do not warn about it: if it is set to 263 + // something else, the user adjusted it on their own. 264 + 265 + // NOTE: We populate a stopwords table at "phabricator_search.stopwords", 266 + // but the default InnoDB stopword list is pretty reasonable (36 words, 267 + // versus 500+ in MyISAM). Just use the builtin list until we run into 268 + // concrete issues with it. Users can switch to our stopword table with: 269 + // 270 + // [mysqld] 271 + // innodb_ft_server_stopword_table = phabricator_search/stopwords 250 272 251 273 $innodb_pool = $ref->loadRawMySQLConfigValue('innodb_buffer_pool_size'); 252 274 $innodb_bytes = phutil_parse_bytes($innodb_pool);
+6 -1
src/applications/config/schema/PhabricatorConfigSchemaSpec.php
··· 63 63 $database = $this->getDatabase($database_name); 64 64 65 65 $table = $this->newTable($table_name); 66 - $fulltext_engine = 'MyISAM'; 66 + 67 + if (PhabricatorSearchDocument::isInnoDBFulltextEngineAvailable()) { 68 + $fulltext_engine = 'InnoDB'; 69 + } else { 70 + $fulltext_engine = 'MyISAM'; 71 + } 67 72 68 73 foreach ($columns as $name => $type) { 69 74 if ($type === null) {
+15 -5
src/applications/search/storage/document/PhabricatorSearchDocument.php
··· 45 45 46 46 $compiler = new PhutilSearchQueryCompiler(); 47 47 48 - $operators = queryfx_one( 49 - $conn, 50 - 'SELECT @@ft_boolean_syntax AS syntax'); 51 - if ($operators) { 52 - $compiler->setOperators($operators['syntax']); 48 + if (self::isInnoDBFulltextEngineAvailable()) { 49 + // The InnoDB fulltext boolean operators are always the same as the 50 + // default MyISAM operators, so we do not need to adjust the compiler. 51 + } else { 52 + $operators = queryfx_one( 53 + $conn, 54 + 'SELECT @@ft_boolean_syntax AS syntax'); 55 + if ($operators) { 56 + $compiler->setOperators($operators['syntax']); 57 + } 53 58 } 54 59 55 60 return $compiler; 61 + } 62 + 63 + public static function isInnoDBFulltextEngineAvailable() { 64 + // For now, never consider this engine to be available. 65 + return false; 56 66 } 57 67 58 68 }