http://www.mediawiki.org/wiki/Special:Code/MediaWiki/58271
Revision: 58271 Author: maxsem Date: 2009-10-28 18:45:26 +0000 (Wed, 28 Oct 2009) Log Message: ----------- * Nah, using the embedded rowid column broke search index updates hopelessly. * Renamed FTS-related SQL scripts, these are not upgrade patches per se. Modified Paths: -------------- branches/sqlite/includes/search/SearchSqlite.php branches/sqlite/maintenance/updaters.inc Added Paths: ----------- branches/sqlite/maintenance/sqlite/archives/searchindex-fts3.sql branches/sqlite/maintenance/sqlite/archives/searchindex-no-fts.sql Removed Paths: ------------- branches/sqlite/maintenance/sqlite/archives/patch-fts3-searchindex.sql branches/sqlite/maintenance/sqlite/archives/patch-searchindex-no-fts.sql Modified: branches/sqlite/includes/search/SearchSqlite.php =================================================================== --- branches/sqlite/includes/search/SearchSqlite.php 2009-10-28 18:40:57 UTC (rev 58270) +++ branches/sqlite/includes/search/SearchSqlite.php 2009-10-28 18:45:26 UTC (rev 58271) @@ -1,4 +1,6 @@ <?php +# SQLite search backend, based upon SearchMysql +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -256,9 +258,9 @@ $match = $this->parseQuery( $filteredTerm, $fulltext ); $page = $this->db->tableName( 'page' ); $searchindex = $this->db->tableName( 'searchindex' ); - return "SELECT $searchindex.rowid, page_namespace, page_title " . + return "SELECT si_page, page_namespace, page_title " . "FROM $page,$searchindex " . - "WHERE page_id=$searchindex.rowid AND $match"; + "WHERE page_id=si_page AND $match"; } function getCountQuery( $filteredTerm, $fulltext ) { @@ -267,7 +269,7 @@ $searchindex = $this->db->tableName( 'searchindex' ); return "SELECT COUNT(*) AS c " . "FROM $page,$searchindex " . - "WHERE page_id=$searchindex.rowid AND $match" . + "WHERE page_id=si_page AND $match" . $this->queryRedirect() . ' ' . $this->queryNamespaces(); } @@ -283,9 +285,9 @@ function update( $id, $title, $text ) { $dbw = wfGetDB( DB_MASTER ); $dbw->replace( 'searchindex', - array( 'rowid' ), + array( 'si_page' ), array( - 'rowid' => $id, + 'si_page' => $id, 'si_title' => $title, 'si_text' => $text ), __METHOD__ ); @@ -303,7 +305,7 @@ $dbw->update( 'searchindex', array( 'si_title' => $title ), - array( 'rowid' => $id ), + array( 'si_page' => $id ), __METHOD__, array( $dbw->lowPriorityOption() ) ); } Deleted: branches/sqlite/maintenance/sqlite/archives/patch-fts3-searchindex.sql =================================================================== --- branches/sqlite/maintenance/sqlite/archives/patch-fts3-searchindex.sql 2009-10-28 18:40:57 UTC (rev 58270) +++ branches/sqlite/maintenance/sqlite/archives/patch-fts3-searchindex.sql 2009-10-28 18:45:26 UTC (rev 58271) @@ -1,18 +0,0 @@ --- Patch that introduces fulltext search capabilities to SQLite schema --- Requires that SQLite must be compiled with FTS3 module (comes with core amalgamation). --- See http://www.sqlite.org/cvstrac/wiki?p=FtsUsage for details of syntax. --- Will fail if FTS3 is not present, -DROP TABLE IF EXISTS /*_*/searchindex; -CREATE VIRTUAL TABLE /*_*/searchindex USING FTS3( - -- Key to page_id - -- Disabled, instead we use the built-in rowid column - --si_page INTEGER NOT NULL, - - -- Munged version of title - si_title, - - -- Munged version of body text - si_text -); - -INSERT INTO /*_*/updatelog VALUES ('fts3'); \ No newline at end of file Deleted: branches/sqlite/maintenance/sqlite/archives/patch-searchindex-no-fts.sql =================================================================== --- branches/sqlite/maintenance/sqlite/archives/patch-searchindex-no-fts.sql 2009-10-28 18:40:57 UTC (rev 58270) +++ branches/sqlite/maintenance/sqlite/archives/patch-searchindex-no-fts.sql 2009-10-28 18:45:26 UTC (rev 58271) @@ -1,24 +0,0 @@ --- Searchindex table definition for cases when no full-text search SQLite module is present --- (currently, only FTS3 is supported). --- Use it if you are moving your database from environment with FTS support --- to environment without it. - -DROP TABLE IF EXISTS /*_*/searchindex; - --- These are pieces of FTS3-enabled searchindex -DROP TABLE IF EXISTS /*_*/searchindex_content; -DROP TABLE IF EXISTS /*_*/searchindex_segdir; -DROP TABLE IF EXISTS /*_*/searchindex_segments; - -CREATE TABLE /*_*/searchindex ( - -- Key to page_id - -- si_page INTEGER NOT NULL, - - -- Munged version of title - si_title TEXT, - - -- Munged version of body text - si_text TEXT -); - -DELETE FROM /*_*/updatelog WHERE ul_key='fts3'; \ No newline at end of file Copied: branches/sqlite/maintenance/sqlite/archives/searchindex-fts3.sql (from rev 58250, branches/sqlite/maintenance/sqlite/archives/patch-fts3-searchindex.sql) =================================================================== --- branches/sqlite/maintenance/sqlite/archives/searchindex-fts3.sql (rev 0) +++ branches/sqlite/maintenance/sqlite/archives/searchindex-fts3.sql 2009-10-28 18:45:26 UTC (rev 58271) @@ -0,0 +1,17 @@ +-- Patch that introduces fulltext search capabilities to SQLite schema +-- Requires that SQLite must be compiled with FTS3 module (comes with core amalgamation). +-- See http://www.sqlite.org/cvstrac/wiki?p=FtsUsage for details of syntax. +-- Will fail if FTS3 is not present, +DROP TABLE IF EXISTS /*_*/searchindex; +CREATE VIRTUAL TABLE /*_*/searchindex USING FTS3( + -- Key to page_id + si_page INTEGER NOT NULL, + + -- Munged version of title + si_title, + + -- Munged version of body text + si_text +); + +INSERT INTO /*_*/updatelog VALUES ('fts3'); \ No newline at end of file Copied: branches/sqlite/maintenance/sqlite/archives/searchindex-no-fts.sql (from rev 58250, branches/sqlite/maintenance/sqlite/archives/patch-searchindex-no-fts.sql) =================================================================== --- branches/sqlite/maintenance/sqlite/archives/searchindex-no-fts.sql (rev 0) +++ branches/sqlite/maintenance/sqlite/archives/searchindex-no-fts.sql 2009-10-28 18:45:26 UTC (rev 58271) @@ -0,0 +1,24 @@ +-- Searchindex table definition for cases when no full-text search SQLite module is present +-- (currently, only FTS3 is supported). +-- Use it if you are moving your database from environment with FTS support +-- to environment without it. + +DROP TABLE IF EXISTS /*_*/searchindex; + +-- These are pieces of FTS3-enabled searchindex +DROP TABLE IF EXISTS /*_*/searchindex_content; +DROP TABLE IF EXISTS /*_*/searchindex_segdir; +DROP TABLE IF EXISTS /*_*/searchindex_segments; + +CREATE TABLE /*_*/searchindex ( + -- Key to page_id + si_page INTEGER NOT NULL, + + -- Munged version of title + si_title TEXT, + + -- Munged version of body text + si_text TEXT +); + +DELETE FROM /*_*/updatelog WHERE ul_key='fts3'; \ No newline at end of file Modified: branches/sqlite/maintenance/updaters.inc =================================================================== --- branches/sqlite/maintenance/updaters.inc 2009-10-28 18:40:57 UTC (rev 58270) +++ branches/sqlite/maintenance/updaters.inc 2009-10-28 18:45:26 UTC (rev 58271) @@ -1290,11 +1290,11 @@ $fts3tTable = update_row_exists( 'fts3' ); if ( $fts3tTable && !$module ) { wfOut( '...PHP is missing FTS3 support, downgrading tables...' ); - $wgDatabase->sourceFile( archive( 'patch-searchindex-no-fts.sql' ) ); + $wgDatabase->sourceFile( archive( 'searchindex-no-fts.sql' ) ); wfOut( "done\n" ); } elseif ( !$fts3tTable && $module == 'FTS3' ) { wfOut( '...adding FTS3 search capabilities...' ); - $wgDatabase->sourceFile( archive( 'patch-fts3-searchindex.sql' ) ); + $wgDatabase->sourceFile( archive( 'searchindex-fts3.sql' ) ); wfOut( "done\n" ); } else { wfOut( "...fulltext search table appears to be in order.\n" ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs