mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 15:22:41 +01:00
Fix an issue with collation construction on "sort" columns for old MySQL
Summary: Fixes T7422. We'll currently choose a "binary" charset with a "utf8_general_ci" collation on "sort" columns on older MySQL, which seems to be causing problems. Choose "utf8" in this case instead. (I attempted to simplify the logic, too, but that's the only actual change.) Test Plan: Went back and forth with `--disable-utf8mb4` on `storage adjust`, but this is version dependent so I'm not 100% sure it's the right fix. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7422 Differential Revision: https://secure.phabricator.com/D11928
This commit is contained in:
parent
a65667443b
commit
184619730f
1 changed files with 50 additions and 28 deletions
|
@ -235,36 +235,58 @@ abstract class PhabricatorConfigSchemaSpec extends Phobject {
|
|||
$type = $matches[1];
|
||||
$size = idx($matches, 2);
|
||||
|
||||
if ($is_binary) {
|
||||
if ($size) {
|
||||
$column_type = 'varbinary('.$size.')';
|
||||
} else {
|
||||
$column_type = 'longblob';
|
||||
}
|
||||
|
||||
// MySQL (at least, under MyISAM) refuses to create a FULLTEXT index
|
||||
// on a LONGBLOB column. We'd also lose case insensitivity in search.
|
||||
// Force this column to utf8 collation. This will truncate results with
|
||||
// 4-byte UTF characters in their text, but work reasonably in the
|
||||
// majority of cases.
|
||||
|
||||
if ($type == 'fulltext') {
|
||||
switch ($type) {
|
||||
case 'text':
|
||||
if ($is_binary) {
|
||||
if ($size) {
|
||||
$column_type = 'varbinary('.$size.')';
|
||||
} else {
|
||||
$column_type = 'longblob';
|
||||
}
|
||||
} else {
|
||||
if ($size) {
|
||||
$column_type = 'varchar('.$size.')';
|
||||
} else {
|
||||
$column_type = 'longtext';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'sort':
|
||||
if ($size) {
|
||||
$column_type = 'varchar('.$size.')';
|
||||
} else {
|
||||
$column_type = 'longtext';
|
||||
}
|
||||
break;
|
||||
case 'fulltext';
|
||||
// MySQL (at least, under MyISAM) refuses to create a FULLTEXT index
|
||||
// on a LONGBLOB column. We'd also lose case insensitivity in search.
|
||||
// Force this column to utf8 collation. This will truncate results
|
||||
// with 4-byte UTF characters in their text, but work reasonably in
|
||||
// the majority of cases.
|
||||
$column_type = 'longtext';
|
||||
$charset = 'utf8';
|
||||
$collation = 'utf8_general_ci';
|
||||
}
|
||||
} else {
|
||||
if ($size) {
|
||||
$column_type = 'varchar('.$size.')';
|
||||
} else {
|
||||
$column_type = 'longtext';
|
||||
}
|
||||
$charset = $this->getUTF8Charset();
|
||||
if ($type == 'sort' || $type == 'fulltext') {
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'text':
|
||||
if ($is_binary) {
|
||||
// We leave collation and character set unspecified in order to
|
||||
// generate valid SQL.
|
||||
} else {
|
||||
$charset = $this->getUTF8Charset();
|
||||
$collation = $this->getUTF8BinaryCollation();
|
||||
}
|
||||
break;
|
||||
case 'sort':
|
||||
case 'fulltext':
|
||||
if ($is_binary) {
|
||||
$charset = 'utf8';
|
||||
} else {
|
||||
$charset = $this->getUTF8Charset();
|
||||
}
|
||||
$collation = $this->getUTF8SortingCollation();
|
||||
} else {
|
||||
$collation = $this->getUTF8BinaryCollation();
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ($data_type) {
|
||||
|
|
Loading…
Reference in a new issue