[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorConfigKeySchema 4 extends PhabricatorConfigStorageSchema { 5 6 const MAX_INNODB_KEY_LENGTH = 767; 7 8 private $columnNames; 9 private $unique; 10 private $table; 11 private $indexType; 12 13 public function setIndexType($index_type) { 14 $this->indexType = $index_type; 15 return $this; 16 } 17 18 public function getIndexType() { 19 return $this->indexType; 20 } 21 22 public function setProperty($property) { 23 $this->property = $property; 24 return $this; 25 } 26 27 public function getProperty() { 28 return $this->property; 29 } 30 31 public function setUnique($unique) { 32 $this->unique = $unique; 33 return $this; 34 } 35 36 public function getUnique() { 37 return $this->unique; 38 } 39 40 public function setTable(PhabricatorConfigTableSchema $table) { 41 $this->table = $table; 42 return $this; 43 } 44 45 public function getTable() { 46 return $this->table; 47 } 48 49 public function setColumnNames(array $column_names) { 50 $this->columnNames = array_values($column_names); 51 return $this; 52 } 53 54 public function getColumnNames() { 55 return $this->columnNames; 56 } 57 58 protected function getSubschemata() { 59 return array(); 60 } 61 62 public function getKeyColumnAndPrefix($column_name) { 63 $matches = null; 64 if (preg_match('/^(.*)\((\d+)\)\z/', $column_name, $matches)) { 65 return array($matches[1], (int)$matches[2]); 66 } else { 67 return array($column_name, null); 68 } 69 } 70 71 public function getKeyByteLength() { 72 $size = 0; 73 foreach ($this->getColumnNames() as $column_spec) { 74 list($column_name, $prefix) = $this->getKeyColumnAndPrefix($column_spec); 75 $column = $this->getTable()->getColumn($column_name); 76 if (!$column) { 77 $size = 0; 78 break; 79 } 80 $size += $column->getKeyByteLength($prefix); 81 } 82 83 return $size; 84 } 85 86 public function compareToSimilarSchema( 87 PhabricatorConfigStorageSchema $expect) { 88 89 $issues = array(); 90 if ($this->getColumnNames() !== $expect->getColumnNames()) { 91 $issues[] = self::ISSUE_KEYCOLUMNS; 92 } 93 94 if ($this->getUnique() !== $expect->getUnique()) { 95 $issues[] = self::ISSUE_UNIQUE; 96 } 97 98 // A fulltext index can be of any length. 99 if ($this->getIndexType() != 'FULLTEXT') { 100 if ($this->getKeyByteLength() > self::MAX_INNODB_KEY_LENGTH) { 101 $issues[] = self::ISSUE_LONGKEY; 102 } 103 } 104 105 return $issues; 106 } 107 108 public function newEmptyClone() { 109 $clone = clone $this; 110 $this->table = null; 111 return $clone; 112 } 113 114 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |