1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Fix quickstart.sql for old MySQL

Summary:
Fixes T7422. After the recent fix for "sort" columns, we can end up with invalid SQL in some cases when running quickstart.

In particular, we do "COLLATE binary CHARACTER SET utf8_general_ci" (which is invalid).

Preprocess these so we get "COLLATE utf8 CHARACTER SET utf8_general_ci" (which is valid and correct).

Test Plan: Ran `bin/storage upgrade -f --namespace blahblhbaba` with and without `--disable-utf8mb4`.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7422

Differential Revision: https://secure.phabricator.com/D11929
This commit is contained in:
epriestley 2015-03-02 09:57:38 -08:00
parent 8fd77ff4f8
commit a65667443b
3 changed files with 82 additions and 19 deletions

File diff suppressed because one or more lines are too long

View file

@ -11,6 +11,7 @@ final class PhabricatorStorageManagementAPI {
private $disableUTF8MB4;
const CHARSET_DEFAULT = 'CHARSET';
const CHARSET_SORT = 'CHARSET_SORT';
const CHARSET_FULLTEXT = 'CHARSET_FULLTEXT';
const COLLATE_TEXT = 'COLLATE_TEXT';
const COLLATE_SORT = 'COLLATE_SORT';
@ -254,6 +255,7 @@ final class PhabricatorStorageManagementAPI {
// collation. This is most correct, and will sort properly.
$charset = 'utf8mb4';
$charset_sort = 'utf8mb4';
$charset_full = 'utf8mb4';
$collate_text = 'utf8mb4_bin';
$collate_sort = 'utf8mb4_unicode_ci';
@ -282,6 +284,7 @@ final class PhabricatorStorageManagementAPI {
// are not giving up too much.
$charset = 'binary';
$charset_sort = 'utf8';
$charset_full = 'utf8';
$collate_text = 'binary';
$collate_sort = 'utf8_general_ci';
@ -290,6 +293,7 @@ final class PhabricatorStorageManagementAPI {
return array(
self::CHARSET_DEFAULT => $charset,
self::CHARSET_SORT => $charset_sort,
self::CHARSET_FULLTEXT => $charset_full,
self::COLLATE_TEXT => $collate_text,
self::COLLATE_SORT => $collate_sort,

View file

@ -113,6 +113,16 @@ final class PhabricatorStorageManagementQuickstartWorkflow
'{$CHARSET}',
$dump);
$old = $dump;
$dump = preg_replace(
'/CHARACTER SET {\$CHARSET} COLLATE {\$COLLATE_SORT}/mi',
'CHARACTER SET {$CHARSET_SORT} COLLATE {$COLLATE_SORT}',
$dump);
if ($dump == $old) {
throw new PhutilArgumentUsageException(
pht('Failed to adjust SORT columns!'));
}
// Strip out a bunch of unnecessary commands which make the dump harder
// to handle and slower to import.