http://www.mediawiki.org/wiki/Special:Code/MediaWiki/63080
Revision: 63080 Author: demon Date: 2010-02-28 16:38:37 +0000 (Sun, 28 Feb 2010) Log Message: ----------- Redo table options to be an array and fix searchindex, hitcounter, revision and text to use them. Also fix constant refs Modified Paths: -------------- branches/new-installer/phase3/includes/installer/Schema.php branches/new-installer/phase3/includes/installer/SchemaBuilder.php Modified: branches/new-installer/phase3/includes/installer/Schema.php =================================================================== --- branches/new-installer/phase3/includes/installer/Schema.php 2010-02-28 16:35:33 UTC (rev 63079) +++ branches/new-installer/phase3/includes/installer/Schema.php 2010-02-28 16:38:37 UTC (rev 63080) @@ -18,7 +18,6 @@ * * @author Chad Horohoe <c...@anyonecanedit.org> * @todo FOLLOWING TABLES NEED WORK: - * -searchindex, hitcounter (custom table options) * -externallinks, ipblocks, oldimage, job (indexes) * -trackbacks, testitem (REFERENCES) */ @@ -374,6 +373,10 @@ 'user_text', 'timestamp', ), ), + 'options' => array( + 'max_rows' => 10000000, + 'avg_row_length' => 1024, + ), ), 'text' => array( 'prefix' => 'old', @@ -397,6 +400,10 @@ ), ), 'indexes' => array(), + 'options' => array( + 'max_rows' => 10000000, + 'avg_row_length' => 10240, + ), ), 'archive' => array( 'prefix' => 'ar', @@ -809,6 +816,10 @@ 'null' => false, ), ), + 'options' => array( + 'max_rows' => 25000, + 'engine' => 'HEAP', + ), ), 'ipblocks' => array( 'prefix' => 'ipb', Modified: branches/new-installer/phase3/includes/installer/SchemaBuilder.php =================================================================== --- branches/new-installer/phase3/includes/installer/SchemaBuilder.php 2010-02-28 16:35:33 UTC (rev 63079) +++ branches/new-installer/phase3/includes/installer/SchemaBuilder.php 2010-02-28 16:38:37 UTC (rev 63080) @@ -115,24 +115,14 @@ } /** - * Set the prefix for all tables (unless they override this) - * - * @param $opts String The options for all tables, like ENGINE=InnoDB + * Set the default table options for all tables + * @param $opts Array of table options, like 'engine' => 'InnoDB', etc */ public function setTableOptions( $opts ) { $this->tblOptions = $opts; } /** - * Get table options - * - * @return String - */ - protected function getTableOptions() { - return $this->tblOptions; - } - - /** * Given an abstract table definition, return a DBMS-specific command to * create it. * @param $name The name of the table, like 'page' or 'revision' @@ -164,18 +154,18 @@ 'prefix' => 'si', 'fields' => array( 'page' => array( - 'type' => self::TYPE_INT, + 'type' => Schema::TYPE_INT, 'signed' => false, 'null' => false, ), 'title' => array( - 'type' => self::TYPE_VARCHAR, + 'type' => Schema::TYPE_VARCHAR, 'length' => 255, 'null' => false, 'default' => '', ), 'text' => array( - 'type' => self::TYPE_TEXT, + 'type' => Schema::TYPE_TEXT, 'length' => 'medium', 'null' => false, ), @@ -191,6 +181,9 @@ 'FULLTEXT', 'text', ), ), + 'options' => array( + 'engine' => 'MyISAM', + ), ); } @@ -200,12 +193,13 @@ protected function createTable( $name, $def ) { $prefix = $def['prefix'] ? $def['prefix'] . '_' : ''; $tblName = $this->tblPrefix . $name; + $opts = isset( $def['options'] ) ? $def['options'] : array(); $sql = "CREATE TABLE `$tblName` ("; foreach( $def['fields'] as $field => $attribs ) { $sql .= "\n\t{$prefix}{$field} " . $this->getFieldDefinition( $attribs ); } $sql = rtrim( $sql, ',' ); - $sql .= "\n) " . $this->getTableOptions() . ";\n"; + $sql .= "\n) " . $this->getTableOptions( $opts ) . ";\n"; if( isset( $def['indexes'] ) ) { foreach( $def['indexes'] as $idx => $idxDef ) { if( $idxDef[0] === 'UNIQUE' ) { @@ -316,6 +310,15 @@ return $def . ","; } + private function getTableOptions( $opts ) { + $opts = array_merge( $this->tblOptions, $opts ); + $ret = array(); + foreach( $opts as $name => $value ) { + $ret[] = strtoupper( $name ) . "=$value"; + } + return implode( ', ', $ret ); + } + protected function updateTable( $name, $definition, $db ) { return ''; } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs