r90460 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90459‎ | r90460 | r90461 >
Date:13:17, 20 June 2011
Author:jeroendedauw
Status:deferred (Comments)
Tags:
Comment:
partial revert of r90358, patch breaks stuff
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -3,7 +3,7 @@
44 /**
55 * New SQL implementation of SMW's storage abstraction layer.
66 *
7 - * @author Markus Krötzsch
 7+ * @author Markus Krötzsch
88 * @author Jeroen De Dauw
99 *
1010 * @file
@@ -977,7 +977,7 @@
978978 } // else: properties with special tables are ignored for now; maybe fix in the future
979979 }
980980
981 - $query = 'SELECT * FROM (' . implode( ') UNION (', $queries ) . ') ORDER BY smw_sortkey';
 981+ $query = '(' . implode( ') UNION (', $queries ) . ') ORDER BY smw_sortkey';
982982 // The following line is possible in MW 1.6 and above only:
983983 // $query = $db->unionQueries($queries, false) . ' ORDER BY smw_sortkey'; // should probably use $db->makeSelectOptions()
984984 if ( $requestoptions !== null ) {
@@ -1028,21 +1028,14 @@
10291029 . "$$ "
10301030 . "LANGUAGE 'plpgsql'; "
10311031 . "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) )";
10341032 } else { // MySQL: use temporary in-memory table
10351033 $sql = "CREATE TEMPORARY TABLE " . $smw_tmp_unusedprops . "( title VARCHAR(255) ) ENGINE=MEMORY";
10361034 }
10371035
10381036 $db->query( $sql, $fname );
10391037
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 );
10471040
10481041 $smw_ids = $db->tableName( 'smw_ids' );
10491042
@@ -1052,19 +1045,8 @@
10531046 // all tables occurring in some property table are used:
10541047 foreach ( self::getPropertyTables() as $proptable ) {
10551048 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 );
10691051 } // else: todo
10701052 }
10711053
@@ -1074,17 +1056,8 @@
10751057 $subPropertyTable = $propertyTables[$subPropertyTableId];
10761058
10771059 // (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 );
10891062 // properties that are redirects are considered to be used:
10901063 // (a stricter and more costy approach would be to delete only redirects to used properties;
10911064 // this would need to be done with an addtional query in the above loop)
@@ -1103,10 +1076,7 @@
11041077
11051078 $db->freeResult( $res );
11061079
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 );
11111081 wfProfileOut( "SMWSQLStore2::getUnusedPropertiesSpecial (SMW)" );
11121082
11131083 return $result;
@@ -1245,8 +1215,8 @@
12461216 't' => SMWSQLHelpers::getStandardDBType( 'title' ),
12471217 'l' => SMWSQLHelpers::getStandardDBType( 'blob' ),
12481218 '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' ),
12511221 'p' => SMWSQLHelpers::getStandardDBType( 'id' ),
12521222 'n' => SMWSQLHelpers::getStandardDBType( 'namespace' ),
12531223 'w' => SMWSQLHelpers::getStandardDBType( 'iw' )
@@ -1267,7 +1237,7 @@
12681238 SMWSQLHelpers::setupTable(
12691239 'smw_ids',
12701240 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' ),
12721242 'smw_namespace' => $dbtypes['n'] . ' NOT NULL',
12731243 'smw_title' => $dbtypes['t'] . ' NOT NULL',
12741244 'smw_iw' => $dbtypes['w'],

Follow-up revisions

RevisionCommit summaryAuthorDate
r90464follow up to r90460jeroendedauw14:44, 20 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90358applying modified SQLite patch by hofoenjeroendedauw19:51, 18 June 2011

Comments

#Comment by Nikerabbit (talk | contribs)   14:22, 20 June 2011

Broke encoding:

+ * @author Markus Krötzsch