http://www.mediawiki.org/wiki/Special:Code/MediaWiki/58289
Revision: 58289 Author: maxsem Date: 2009-10-28 21:38:50 +0000 (Wed, 28 Oct 2009) Log Message: ----------- Now seems to really work Modified Paths: -------------- branches/sqlite/includes/db/DatabaseSqlite.php branches/sqlite/includes/search/SearchSqlite.php branches/sqlite/maintenance/sqlite/archives/searchindex-fts3.sql branches/sqlite/maintenance/sqlite/archives/searchindex-no-fts.sql branches/sqlite/maintenance/updaters.inc Modified: branches/sqlite/includes/db/DatabaseSqlite.php =================================================================== --- branches/sqlite/includes/db/DatabaseSqlite.php 2009-10-28 21:30:41 UTC (rev 58288) +++ branches/sqlite/includes/db/DatabaseSqlite.php 2009-10-28 21:38:50 UTC (rev 58289) @@ -100,7 +100,7 @@ * Returns version of currently supported SQLite fulltext search module or false if none present. * @return String */ - function fulltextSearchModule() { + function getFulltextSearchModule() { $table = 'dummy_search_test'; $this->query( "DROP TABLE IF EXISTS $table", __METHOD__ ); if ( $this->query( "CREATE VIRTUAL TABLE $table USING FTS3(dummy_field)", __METHOD__, true ) ) { Modified: branches/sqlite/includes/search/SearchSqlite.php =================================================================== --- branches/sqlite/includes/search/SearchSqlite.php 2009-10-28 21:30:41 UTC (rev 58288) +++ branches/sqlite/includes/search/SearchSqlite.php 2009-10-28 21:38:50 UTC (rev 58289) @@ -263,9 +263,9 @@ $match = $this->parseQuery( $filteredTerm, $fulltext ); $page = $this->db->tableName( 'page' ); $searchindex = $this->db->tableName( 'searchindex' ); - return "SELECT si_page, page_namespace, page_title " . + return "SELECT $searchindex.rowid, page_namespace, page_title " . "FROM $page,$searchindex " . - "WHERE page_id=si_page AND $match"; + "WHERE page_id=$searchindex.rowid AND $match"; } function getCountQuery( $filteredTerm, $fulltext ) { @@ -274,7 +274,7 @@ $searchindex = $this->db->tableName( 'searchindex' ); return "SELECT COUNT(*) AS c " . "FROM $page,$searchindex " . - "WHERE page_id=si_page AND $match" . + "WHERE page_id=$searchindex.rowid AND $match" . $this->queryRedirect() . ' ' . $this->queryNamespaces(); } @@ -288,11 +288,15 @@ * @param $text String */ function update( $id, $title, $text ) { + // @todo: find a method to do it in a single request, + // couldn't do it so far due to typelessness of FTS3 tables. $dbw = wfGetDB( DB_MASTER ); - $dbw->replace( 'searchindex', - array( 'si_page' ), + + $dbw->delete( 'searchindex', array( 'rowid' => $id ), __METHOD__ ); + + $dbw->insert( 'searchindex', array( - 'si_page' => $id, + 'rowid' => $id, 'si_title' => $title, 'si_text' => $text ), __METHOD__ ); @@ -309,8 +313,8 @@ $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'searchindex', + array( 'rowid' => $id ), array( 'si_title' => $title ), - array( 'si_page' => $id ), __METHOD__ ); } } Modified: branches/sqlite/maintenance/sqlite/archives/searchindex-fts3.sql =================================================================== --- branches/sqlite/maintenance/sqlite/archives/searchindex-fts3.sql 2009-10-28 21:30:41 UTC (rev 58288) +++ branches/sqlite/maintenance/sqlite/archives/searchindex-fts3.sql 2009-10-28 21:38:50 UTC (rev 58289) @@ -5,7 +5,8 @@ DROP TABLE IF EXISTS /*_*/searchindex; CREATE VIRTUAL TABLE /*_*/searchindex USING FTS3( -- Key to page_id - si_page INTEGER NOT NULL, + -- Disabled, instead we use the built-in rowid column + -- si_page INTEGER NOT NULL, -- Munged version of title si_title, Modified: branches/sqlite/maintenance/sqlite/archives/searchindex-no-fts.sql =================================================================== --- branches/sqlite/maintenance/sqlite/archives/searchindex-no-fts.sql 2009-10-28 21:30:41 UTC (rev 58288) +++ branches/sqlite/maintenance/sqlite/archives/searchindex-no-fts.sql 2009-10-28 21:38:50 UTC (rev 58289) @@ -12,7 +12,8 @@ CREATE TABLE /*_*/searchindex ( -- Key to page_id - si_page INTEGER NOT NULL, + -- Disabled, instead we use the built-in rowid column + -- si_page INTEGER NOT NULL, -- Munged version of title si_title TEXT, Modified: branches/sqlite/maintenance/updaters.inc =================================================================== --- branches/sqlite/maintenance/updaters.inc 2009-10-28 21:30:41 UTC (rev 58288) +++ branches/sqlite/maintenance/updaters.inc 2009-10-28 21:38:50 UTC (rev 58289) @@ -1286,7 +1286,7 @@ function sqlite_setup_searchindex() { global $wgDatabase; - $module = $wgDatabase->fulltextSearchModule(); + $module = $wgDatabase->getFulltextSearchModule(); $fts3tTable = update_row_exists( 'fts3' ); if ( $fts3tTable && !$module ) { wfOut( '...PHP is missing FTS3 support, downgrading tables...' ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs