Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -1086,9 +1086,20 @@ |
1087 | 1087 | |
1088 | 1088 | // all tables occurring in some property table are used: |
1089 | 1089 | 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__ ); |
1093 | 1104 | } // else: todo |
1094 | 1105 | } |
1095 | 1106 | |
— | — | @@ -1097,9 +1108,18 @@ |
1098 | 1109 | $subPropertyTableId = self::$special_tables['_SUBP']; |
1099 | 1110 | $subPropertyTable = $propertyTables[$subPropertyTableId]; |
1100 | 1111 | |
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 | + |
1104 | 1124 | // properties that are redirects are considered to be used: |
1105 | 1125 | // (a stricter and more costy approach would be to delete only redirects to used properties; |
1106 | 1126 | // this would need to be done with an addtional query in the above loop) |
— | — | @@ -1118,7 +1138,8 @@ |
1119 | 1139 | |
1120 | 1140 | $db->freeResult( $res ); |
1121 | 1141 | |
1122 | | - $db->query( "DROP TEMPORARY table $smw_tmp_unusedprops", __METHOD__ ); |
| 1142 | + $db->query( "DROP " . ( $wgDBtype == 'postgres' ? '' : 'TEMPORARY' ) . |
| 1143 | + " TABLE $smw_tmp_unusedprops", __METHOD__ ); |
1123 | 1144 | wfProfileOut( "SMWSQLStore2::getUnusedPropertiesSpecial (SMW)" ); |
1124 | 1145 | |
1125 | 1146 | return $result; |