r25988 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25987‎ | r25988 | r25989 >
Date:13:57, 21 September 2007
Author:proes
Status:old
Tags:
Comment:
Replaced 'Create uw_expression indices.sql' by PHP code.
Modified paths:
  • /trunk/extensions/Wikidata/Database+scripts/Convenience/Create+uw_expression+indices.sql (deleted) (history)
  • /trunk/extensions/Wikidata/Database+scripts/Convenience/DatabaseUtilities.php (modified) (history)
  • /trunk/extensions/Wikidata/Database+scripts/Convenience/Recreate+indexes+for+all+tables+for+website.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/Database scripts/Convenience/Create uw_expression indices.sql
@@ -1,15 +0,0 @@
2 -ALTER TABLE `%dc%_expression`
3 - ADD INDEX `versioned_end_expression` (`remove_transaction_id`, `expression_id`, `language_id`),
4 - ADD INDEX `versioned_end_language` (`remove_transaction_id`, `language_id`, `expression_id`),
5 - ADD INDEX `versioned_end_spelling` (`remove_transaction_id`, `spelling` (255), `expression_id`, `language_id`),
6 - ADD INDEX `versioned_start_expression` (`add_transaction_id`, `expression_id`, `language_id`),
7 - ADD INDEX `versioned_start_language` (`add_transaction_id`, `language_id`, `expression_id`),
8 - ADD INDEX `versioned_start_spelling` (`add_transaction_id`, `spelling` (255), `expression_id`, `language_id`),
9 - ADD INDEX `expressions_unique_idx` (`expression_id`,`language_id`),
10 - ADD INDEX `expressions_idx` (`expression_id`),
11 - ADD INDEX `language_idx` (`language_id`)
12 - ;
13 -
Index: trunk/extensions/Wikidata/Database scripts/Convenience/Recreate indexes for all tables for website.php
@@ -59,8 +59,7 @@
6060 $index = array();
6161
6262 foreach ($tableIndex->getColumns() as $column) {
63 - $indexColumn = $column->getIdentifier();
64 -
 63+ $indexColumn = '`' . $column->getIdentifier() . '`';
6564 $length = $column->getLength();
6665
6766 if ($length != null)
@@ -105,7 +104,6 @@
106105 "collection_contents",
107106 "collection",
108107 "defined_meaning",
109 - "expression",
110108 "meaning_relations",
111109 "option_attribute_options",
112110 "option_attribute_values",
@@ -117,11 +115,11 @@
118116
119117 $prefixes = retrieve_datasets();
120118
121 -//$dataSet = new WikiDataSet("uw");
122 -//recreateIndexesForTableNew($dataSet->expression);
123 -
124119 foreach($prefixes as $prefix) {
125 - recreateIndexesForTables( $prefix, $tables );
 120+ $dataSet = new WikiDataSet($prefix);
 121+ recreateIndexesForTableNew($dataSet->expression);
 122+
 123+ recreateIndexesForTables($prefix, $tables);
126124 }
127125
128126 $endTime = time();
Index: trunk/extensions/Wikidata/Database scripts/Convenience/DatabaseUtilities.php
@@ -27,15 +27,14 @@
2828 }
2929
3030 function addIndexes($tableName, array $indexes) {
31 - $dbr =& wfGetDB(DB_MASTER);
 31+ if (count($indexes) > 0) {
 32+ $dbr =& wfGetDB(DB_MASTER);
 33+ $indexesSQL = array();
 34+
 35+ foreach ($indexes as $indexName => $columns)
 36+ $indexesSQL[] = " ADD INDEX `" . $indexName . "` (" . implode(", ", $columns) .") ";
3237
33 - $indexesSQL = array();
34 -
35 - foreach ($indexes as $indexName => $columns)
36 - $indexesSQL[] = " ADD INDEX `" . $indexName . "` (" . implode(", ", $columns) .") ";
37 -
38 - $sql = "ALTER TABLE " . $tableName . " " . implode(", ", $indexesSQL);
39 - $dbr->query($sql);
40 -}
41 -
42 -
 38+ $sql = "ALTER TABLE " . $tableName . " " . implode(", ", $indexesSQL);
 39+ $dbr->query($sql);
 40+ }
 41+}
\ No newline at end of file

Status & tagging log