r111256 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111255‎ | r111256 | r111257 >
Date:20:05, 11 February 2012
Author:mkroetzsch
Status:deferred
Tags:
Comment:
added further special cases for PostgreSQL support, hopefully fixing bug 19948
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -1086,9 +1086,20 @@
10871087
10881088 // all tables occurring in some property table are used:
10891089 foreach ( self::getPropertyTables() as $proptable ) {
1090 - if ( $proptable->fixedproperty == false ) { // MW does not seem to have a suitable wrapper for this
1091 - $db->query( "DELETE FROM $smw_tmp_unusedprops USING $smw_tmp_unusedprops INNER JOIN " . $db->tableName( $proptable->name ) .
1092 - " INNER JOIN $smw_ids ON p_id=smw_id AND title=smw_title AND smw_iw=" . $db->addQuotes( '' ), __METHOD__ );
 1090+ if ( $proptable->fixedproperty == false ) {
 1091+ // MW does not seem to have a wrapper for this:
 1092+ if ( $wgDBtype == 'postgres' ) { // PostgresQL: don't repeat the FROM table in USING
 1093+ $sql = "DELETE FROM $smw_tmp_unusedprops USING " .
 1094+ $db->tableName( $proptable->name ) .
 1095+ " INNER JOIN $smw_ids ON p_id=smw_id WHERE" .
 1096+ " title=smw_title AND smw_iw=" . $db->addQuotes( '' );
 1097+ } else {
 1098+ $sql = "DELETE FROM $smw_tmp_unusedprops USING " .
 1099+ "$smw_tmp_unusedprops INNER JOIN " . $db->tableName( $proptable->name ) .
 1100+ " INNER JOIN $smw_ids ON p_id=smw_id AND title=smw_title" .
 1101+ " AND smw_iw=" . $db->addQuotes( '' );
 1102+ }
 1103+ $db->query( $sql, __METHOD__ );
10931104 } // else: todo
10941105 }
10951106
@@ -1097,9 +1108,18 @@
10981109 $subPropertyTableId = self::$special_tables['_SUBP'];
10991110 $subPropertyTable = $propertyTables[$subPropertyTableId];
11001111
1101 - // (again we have no fitting MW wrapper here:)
1102 - $db->query( "DELETE $smw_tmp_unusedprops.* FROM $smw_tmp_unusedprops," . $db->tableName( $subPropertyTable->name ) .
1103 - " INNER JOIN $smw_ids ON o_id=smw_id WHERE title=smw_title", __METHOD__ );
 1112+ // Again we have no fitting MW wrapper here:
 1113+ if ( $wgDBtype == 'postgres' ) { // PostgresQL: don't repeat the FROM table in USING
 1114+ $sql = "DELETE FROM $smw_tmp_unusedprops USING " .
 1115+ $db->tableName( $subPropertyTable->name ) .
 1116+ " INNER JOIN $smw_ids ON o_id=smw_id WHERE title=smw_title";
 1117+ } else {
 1118+ $sql = "DELETE $smw_tmp_unusedprops.* FROM $smw_tmp_unusedprops," .
 1119+ $db->tableName( $subPropertyTable->name ) .
 1120+ " INNER JOIN $smw_ids ON o_id=smw_id WHERE title=smw_title";
 1121+ }
 1122+ $db->query( $sql, __METHOD__ );
 1123+
11041124 // properties that are redirects are considered to be used:
11051125 // (a stricter and more costy approach would be to delete only redirects to used properties;
11061126 // this would need to be done with an addtional query in the above loop)
@@ -1118,7 +1138,8 @@
11191139
11201140 $db->freeResult( $res );
11211141
1122 - $db->query( "DROP TEMPORARY table $smw_tmp_unusedprops", __METHOD__ );
 1142+ $db->query( "DROP " . ( $wgDBtype == 'postgres' ? '' : 'TEMPORARY' ) .
 1143+ " TABLE $smw_tmp_unusedprops", __METHOD__ );
11231144 wfProfileOut( "SMWSQLStore2::getUnusedPropertiesSpecial (SMW)" );
11241145
11251146 return $result;