Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/schema/PhabricatorConfigSchemaSpec.php
Show First 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | private function getDetailsForDataType($data_type) { | ||||
} | } | ||||
// NOTE: MySQL allows fragments like "VARCHAR(32) CHARACTER SET binary", | // NOTE: MySQL allows fragments like "VARCHAR(32) CHARACTER SET binary", | ||||
// but just interprets that to mean "VARBINARY(32)". The fragment is | // but just interprets that to mean "VARBINARY(32)". The fragment is | ||||
// totally disallowed in a MODIFY statement vs a CREATE TABLE statement. | // totally disallowed in a MODIFY statement vs a CREATE TABLE statement. | ||||
$is_binary = ($this->getUTF8Charset() == 'binary'); | $is_binary = ($this->getUTF8Charset() == 'binary'); | ||||
$matches = null; | $matches = null; | ||||
if (preg_match('/^(fulltext|sort|text)(\d+)?\z/', $data_type, $matches)) { | $pattern = '/^(fulltext|sort|text|char)(\d+)?\z/'; | ||||
if (preg_match($pattern, $data_type, $matches)) { | |||||
// Limit the permitted column lengths under the theory that it would | // Limit the permitted column lengths under the theory that it would | ||||
// be nice to eventually reduce this to a small set of standard lengths. | // be nice to eventually reduce this to a small set of standard lengths. | ||||
static $valid_types = array( | static $valid_types = array( | ||||
'text255' => true, | 'text255' => true, | ||||
'text160' => true, | 'text160' => true, | ||||
'text128' => true, | 'text128' => true, | ||||
'text80' => true, | 'text80' => true, | ||||
'text64' => true, | 'text64' => true, | ||||
'text40' => true, | 'text40' => true, | ||||
'text32' => true, | 'text32' => true, | ||||
'text20' => true, | 'text20' => true, | ||||
'text16' => true, | 'text16' => true, | ||||
'text12' => true, | 'text12' => true, | ||||
'text8' => true, | 'text8' => true, | ||||
'text4' => true, | 'text4' => true, | ||||
'text' => true, | 'text' => true, | ||||
'char3' => true, | |||||
'sort255' => true, | 'sort255' => true, | ||||
'sort128' => true, | 'sort128' => true, | ||||
'sort64' => true, | 'sort64' => true, | ||||
'sort32' => true, | 'sort32' => true, | ||||
'sort' => true, | 'sort' => true, | ||||
'fulltext' => true, | 'fulltext' => true, | ||||
); | ); | ||||
Show All 30 Lines | if (preg_match($pattern, $data_type, $matches)) { | ||||
case 'fulltext'; | case 'fulltext'; | ||||
// MySQL (at least, under MyISAM) refuses to create a FULLTEXT index | // MySQL (at least, under MyISAM) refuses to create a FULLTEXT index | ||||
// on a LONGBLOB column. We'd also lose case insensitivity in search. | // on a LONGBLOB column. We'd also lose case insensitivity in search. | ||||
// Force this column to utf8 collation. This will truncate results | // Force this column to utf8 collation. This will truncate results | ||||
// with 4-byte UTF characters in their text, but work reasonably in | // with 4-byte UTF characters in their text, but work reasonably in | ||||
// the majority of cases. | // the majority of cases. | ||||
$column_type = 'longtext'; | $column_type = 'longtext'; | ||||
break; | break; | ||||
case 'char': | |||||
$column_type = 'char('.$size.')'; | |||||
break; | |||||
} | } | ||||
switch ($type) { | switch ($type) { | ||||
case 'text': | case 'text': | ||||
case 'char': | |||||
if ($is_binary) { | if ($is_binary) { | ||||
// We leave collation and character set unspecified in order to | // We leave collation and character set unspecified in order to | ||||
// generate valid SQL. | // generate valid SQL. | ||||
} else { | } else { | ||||
$charset = $this->getUTF8Charset(); | $charset = $this->getUTF8Charset(); | ||||
$collation = $this->getUTF8BinaryCollation(); | $collation = $this->getUTF8BinaryCollation(); | ||||
} | } | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |