1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 09:12: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:
epriestley 2015-03-02 09:57:55 -08:00
parent a65667443b
commit 184619730f

View file

@ -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) {