r64174 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64173‎ | r64174 | r64175 >
Date:19:53, 25 March 2010
Author:maxsem
Status:ok
Tags:
Comment:
new-installer: fixed MySQL indexes
Modified paths:
  • /branches/new-installer/phase3/includes/db/SchemaMysql.php (modified) (history)

Diff [purge]

Index: branches/new-installer/phase3/includes/db/SchemaMysql.php
@@ -1,6 +1,34 @@
22 <?php
33
44 class SchemaMysql extends SchemaBuilder {
 5+ /**
 6+ * BLOB or TEXT fields on MySQL require a length to be specified in
 7+ * index declarations, otherwise CREATE INDEX will fail with error 1170.
 8+ */
 9+ var $indexLengths = array(
 10+ 'el_from' => array(
 11+ 'el_to' => 40,
 12+ ),
 13+ 'el_to' => array(
 14+ 'el_to' => 60,
 15+ ),
 16+ 'el_index' => array(
 17+ 'el_index' => 60,
 18+ ),
 19+ 'ipb_address' => array(
 20+ 'ipb_address' => 255,
 21+ ),
 22+ 'ipb_range' => array(
 23+ 'ipb_range_start' => 8,
 24+ 'ipb_range_end' => 8,
 25+ ),
 26+ 'oi_name_archive_name' => array(
 27+ 'oi_name_archive_name' => 14,
 28+ ),
 29+ 'job_cmd' => array(
 30+ 'job_params' => 128,
 31+ ),
 32+ );
533
634 public function getType() {
735 return 'mysql';
@@ -85,7 +113,11 @@
86114 }
87115 $sql .= "{$this->tblPrefix}{$idx} ON $tblName (";
88116 foreach( $idxDef as $col ) {
89 - $sql .= "{$prefix}{$col}, ";
 117+ $field = "{$prefix}{$col}";
 118+ if ( isset( $this->indexLengths[$idx] ) && isset( $this->indexLengths[$idx][$field] ) ) {
 119+ $field .= "({$this->indexLengths[$idx][$field]})";
 120+ }
 121+ $sql .= "$field, ";
90122 }
91123 $sql = rtrim( $sql, ', ' );
92124 $sql .= ");\n";

Status & tagging log