Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | /** |
5 | 5 | * New SQL implementation of SMW's storage abstraction layer. |
6 | 6 | * |
7 | | - * @author Markus Krötzsch |
| 7 | + * @author Markus Krötzsch |
8 | 8 | * @author Jeroen De Dauw |
9 | 9 | * |
10 | 10 | * @file |
— | — | @@ -977,7 +977,7 @@ |
978 | 978 | } // else: properties with special tables are ignored for now; maybe fix in the future |
979 | 979 | } |
980 | 980 | |
981 | | - $query = 'SELECT * FROM (' . implode( ') UNION (', $queries ) . ') ORDER BY smw_sortkey'; |
| 981 | + $query = '(' . implode( ') UNION (', $queries ) . ') ORDER BY smw_sortkey'; |
982 | 982 | // The following line is possible in MW 1.6 and above only: |
983 | 983 | // $query = $db->unionQueries($queries, false) . ' ORDER BY smw_sortkey'; // should probably use $db->makeSelectOptions() |
984 | 984 | if ( $requestoptions !== null ) { |
— | — | @@ -1028,21 +1028,14 @@ |
1029 | 1029 | . "$$ " |
1030 | 1030 | . "LANGUAGE 'plpgsql'; " |
1031 | 1031 | . "SELECT create_" . $smw_tmp_unusedprops . "(); "; |
1032 | | - } elseif ( $wgDBtype == 'sqlite' ) { // SQLite: no in-memory tables available |
1033 | | - $sql = "CREATE TEMPORARY TABLE " . $smw_tmp_unusedprops . "( title VARCHAR(255) )"; |
1034 | 1032 | } else { // MySQL: use temporary in-memory table |
1035 | 1033 | $sql = "CREATE TEMPORARY TABLE " . $smw_tmp_unusedprops . "( title VARCHAR(255) ) ENGINE=MEMORY"; |
1036 | 1034 | } |
1037 | 1035 | |
1038 | 1036 | $db->query( $sql, $fname ); |
1039 | 1037 | |
1040 | | - $db->insertSelect( |
1041 | | - $smw_tmp_unusedprops, |
1042 | | - 'page', |
1043 | | - array( 'title' => 'page_title' ), |
1044 | | - array( 'page_namespace' => SMW_NS_PROPERTY ), |
1045 | | - $fname |
1046 | | - ); |
| 1038 | + $db->insertSelect( $smw_tmp_unusedprops, 'page', array( 'title' => 'page_title' ), |
| 1039 | + array( "page_namespace" => SMW_NS_PROPERTY ), $fname ); |
1047 | 1040 | |
1048 | 1041 | $smw_ids = $db->tableName( 'smw_ids' ); |
1049 | 1042 | |
— | — | @@ -1052,19 +1045,8 @@ |
1053 | 1046 | // all tables occurring in some property table are used: |
1054 | 1047 | foreach ( self::getPropertyTables() as $proptable ) { |
1055 | 1048 | if ( $proptable->fixedproperty == false ) { // MW does not seem to have a suitable wrapper for this |
1056 | | - if ( $wgDBtype == 'sqlite' ) { // SQLite |
1057 | | - $db->query( |
1058 | | - "DELETE FROM $smw_tmp_unusedprops WHERE title IN (SELECT title FROM $smw_tmp_unusedprops INNER JOIN " . |
1059 | | - $db->tableName( $proptable->name ) . |
1060 | | - " INNER JOIN $smw_ids ON p_id=smw_id AND title=smw_title AND smw_iw=" . |
1061 | | - $db->addQuotes( '' ) . ")", |
1062 | | - $fname |
1063 | | - ); |
1064 | | - } |
1065 | | - else { |
1066 | | - $db->query( "DELETE FROM $smw_tmp_unusedprops USING $smw_tmp_unusedprops INNER JOIN " . $db->tableName( $proptable->name ) . |
1067 | | - " INNER JOIN $smw_ids ON p_id=smw_id AND title=smw_title AND smw_iw=" . $db->addQuotes( '' ), $fname ); |
1068 | | - } |
| 1049 | + $db->query( "DELETE FROM $smw_tmp_unusedprops USING $smw_tmp_unusedprops INNER JOIN " . $db->tableName( $proptable->name ) . |
| 1050 | + " INNER JOIN $smw_ids ON p_id=smw_id AND title=smw_title AND smw_iw=" . $db->addQuotes( '' ), $fname ); |
1069 | 1051 | } // else: todo |
1070 | 1052 | } |
1071 | 1053 | |
— | — | @@ -1074,17 +1056,8 @@ |
1075 | 1057 | $subPropertyTable = $propertyTables[$subPropertyTableId]; |
1076 | 1058 | |
1077 | 1059 | // (again we have no fitting MW wrapper here:) |
1078 | | - if ( $wgDBtype == 'sqlite' ) { // SQLite |
1079 | | - // TODO |
1080 | | - } |
1081 | | - else { |
1082 | | - $db->query( |
1083 | | - "DELETE $smw_tmp_unusedprops.* FROM $smw_tmp_unusedprops," . $db->tableName( $subPropertyTable->name ) . |
1084 | | - " INNER JOIN $smw_ids ON o_id=smw_id WHERE title=smw_title", |
1085 | | - $fname |
1086 | | - ); |
1087 | | - } |
1088 | | - |
| 1060 | + $db->query( "DELETE $smw_tmp_unusedprops.* FROM $smw_tmp_unusedprops," . $db->tableName( $subPropertyTable->name ) . |
| 1061 | + " INNER JOIN $smw_ids ON o_id=smw_id WHERE title=smw_title", $fname ); |
1089 | 1062 | // properties that are redirects are considered to be used: |
1090 | 1063 | // (a stricter and more costy approach would be to delete only redirects to used properties; |
1091 | 1064 | // this would need to be done with an addtional query in the above loop) |
— | — | @@ -1103,10 +1076,7 @@ |
1104 | 1077 | |
1105 | 1078 | $db->freeResult( $res ); |
1106 | 1079 | |
1107 | | - if ( $wgDBtype != 'sqlite' ) { |
1108 | | - $db->query( "DROP TEMPORARY table $smw_tmp_unusedprops", $fname ); |
1109 | | - } |
1110 | | - |
| 1080 | + $db->query( "DROP TEMPORARY table $smw_tmp_unusedprops", $fname ); |
1111 | 1081 | wfProfileOut( "SMWSQLStore2::getUnusedPropertiesSpecial (SMW)" ); |
1112 | 1082 | |
1113 | 1083 | return $result; |
— | — | @@ -1245,8 +1215,8 @@ |
1246 | 1216 | 't' => SMWSQLHelpers::getStandardDBType( 'title' ), |
1247 | 1217 | 'l' => SMWSQLHelpers::getStandardDBType( 'blob' ), |
1248 | 1218 | 'f' => ( $wgDBtype == 'postgres' ? 'DOUBLE PRECISION' : 'DOUBLE' ), |
1249 | | - 'i' => ( ( $wgDBtype == 'postgres' || $wgDBtype == 'sqlite' ) ? 'INTEGER' : 'INT(8)' ), |
1250 | | - 'j' => ( ( $wgDBtype == 'postgres' || $wgDBtype == 'sqlite' ) ? 'INTEGER' : 'INT(8) UNSIGNED' ), |
| 1219 | + 'i' => ( $wgDBtype == 'postgres' ? 'INTEGER' : 'INT(8)' ), |
| 1220 | + 'j' => ( $wgDBtype == 'postgres' ? 'INTEGER' : 'INT(8) UNSIGNED' ), |
1251 | 1221 | 'p' => SMWSQLHelpers::getStandardDBType( 'id' ), |
1252 | 1222 | 'n' => SMWSQLHelpers::getStandardDBType( 'namespace' ), |
1253 | 1223 | 'w' => SMWSQLHelpers::getStandardDBType( 'iw' ) |
— | — | @@ -1267,7 +1237,7 @@ |
1268 | 1238 | SMWSQLHelpers::setupTable( |
1269 | 1239 | 'smw_ids', |
1270 | 1240 | array( |
1271 | | - 'smw_id' => $dbtypes['p'] . ' NOT NULL' . ( $wgDBtype == 'postgres' ? ' PRIMARY KEY' : ( $wgDBtype == 'sqlite' ? ' PRIMARY KEY AUTOINCREMENT' : ' KEY AUTO_INCREMENT' ) ), |
| 1241 | + 'smw_id' => $dbtypes['p'] . ' NOT NULL' . ( $wgDBtype == 'postgres' ? ' PRIMARY KEY' : ' KEY AUTO_INCREMENT' ), |
1272 | 1242 | 'smw_namespace' => $dbtypes['n'] . ' NOT NULL', |
1273 | 1243 | 'smw_title' => $dbtypes['t'] . ' NOT NULL', |
1274 | 1244 | 'smw_iw' => $dbtypes['w'], |