Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/schema/PhabricatorConfigColumnSchema.php
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | final class PhabricatorConfigColumnSchema | ||||
public function getCharacterSet() { | public function getCharacterSet() { | ||||
return $this->characterSet; | return $this->characterSet; | ||||
} | } | ||||
public function getKeyByteLength($prefix = null) { | public function getKeyByteLength($prefix = null) { | ||||
$type = $this->getColumnType(); | $type = $this->getColumnType(); | ||||
$matches = null; | $matches = null; | ||||
if (preg_match('/^varchar\((\d+)\)$/', $type, $matches)) { | if (preg_match('/^(?:var)?char\((\d+)\)$/', $type, $matches)) { | ||||
// For utf8mb4, each character requires 4 bytes. | // For utf8mb4, each character requires 4 bytes. | ||||
$size = (int)$matches[1]; | $size = (int)$matches[1]; | ||||
if ($prefix && $prefix < $size) { | if ($prefix && $prefix < $size) { | ||||
$size = $prefix; | $size = $prefix; | ||||
} | } | ||||
return $size * 4; | return $size * 4; | ||||
} | } | ||||
$matches = null; | $matches = null; | ||||
if (preg_match('/^char\((\d+)\)$/', $type, $matches)) { | if (preg_match('/^(?:var)?binary\((\d+)\)$/', $type, $matches)) { | ||||
// We use char() only for fixed-length binary data, so its size | // binary()/varbinary() store fixed-length binary data, so their size | ||||
// is always the column size. | // is always the column size. | ||||
epriestley: Compensates for `CHARACTER SET binary` being sort of imaginary. | |||||
$size = (int)$matches[1]; | $size = (int)$matches[1]; | ||||
if ($prefix && $prefix < $size) { | if ($prefix && $prefix < $size) { | ||||
$size = $prefix; | $size = $prefix; | ||||
} | } | ||||
return $size; | return $size; | ||||
} | } | ||||
// The "long..." types are arbitrarily long, so just use a big number to | // The "long..." types are arbitrarily long, so just use a big number to | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |
Compensates for CHARACTER SET binary being sort of imaginary.