r65956 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65955‎ | r65956 | r65957 >
Date:16:48, 5 May 2010
Author:yaron
Status:deferred
Tags:
Comment:
Modified and simplified SQL for temporary table so it could work for PostgreSQL as well
Modified paths:
  • /trunk/extensions/SemanticDrilldown/includes/SD_Filter.php (modified) (history)
  • /trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php
@@ -234,15 +234,13 @@
235235 */
236236 function createTempTable( $category, $subcategory, $subcategories, $applied_filters ) {
237237 $dbr = wfGetDB( DB_SLAVE );
238 - $sql = <<<END
239 - CREATE TEMPORARY TABLE semantic_drilldown_values (
240 - id INT NOT NULL,
241 - INDEX id_index (id)
242 - ) AS SELECT ids.smw_id AS id
243 -
244 -END;
245 - $sql .= $this->getSQLFromClause( $category, $subcategory, $subcategories, $applied_filters );
246 - $dbr->query( $sql );
 238+ $sql1 = "CREATE TEMPORARY TABLE semantic_drilldown_values ( id INT NOT NULL )";
 239+ $dbr->query( $sql1 );
 240+ $sql2 = "CREATE INDEX id_index ON semantic_drilldown_values ( id )";
 241+ $dbr->query( $sql2 );
 242+ $sql3 = "INSERT INTO semantic_drilldown_values SELECT ids.smw_id AS id\n";
 243+ $sql3 .= $this->getSQLFromClause( $category, $subcategory, $subcategories, $applied_filters );
 244+ $dbr->query( $sql3 );
247245 }
248246
249247 /**
Index: trunk/extensions/SemanticDrilldown/includes/SD_Filter.php
@@ -204,7 +204,9 @@
205205 */
206206 function dropTempTable() {
207207 $dbr = wfGetDB( DB_SLAVE );
208 - $sql = "DROP TEMPORARY TABLE semantic_drilldown_filter_values";
 208+ // DROP TEMPORARY TABLE would be marginally safer, but it's
 209+ // not supported on all RDBMS's.
 210+ $sql = "DROP TABLE semantic_drilldown_filter_values";
209211 $dbr->query( $sql );
210212 }
211213 }

Status & tagging log