Skip to content

Commit

Permalink
Merge SQLite search from branches/sqlite/ to trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Semenik committed Oct 29, 2009
1 parent 03d3a3f commit 798cfc5
Show file tree
Hide file tree
Showing 8 changed files with 534 additions and 49 deletions.
6 changes: 5 additions & 1 deletion config/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ function setSchema( $schema, $engine ) {
print " done.</li>\n";


if ($conf->DBtype == 'ibm_db2') {
if ( $conf->DBtype == 'ibm_db2' ) {
// Now that table creation is done, make sure everything is committed
// Do this before doing inserts through API
if ($wgDatabase->lastError()) {
Expand All @@ -1279,6 +1279,10 @@ function setSchema( $schema, $engine ) {
print "<li>MediaWiki tables successfully created</li>\n";
$wgDatabase->commit();
}
} elseif ( $conf->DBtype == 'sqlite' ) {
// Ensure proper searchindex format. We have to do that separately because
// if SQLite is compiled without the FTS3 module, table creation syntax will be invalid.
sqlite_setup_searchindex();
}

print "<li>Initializing statistics...</li>\n";
Expand Down
2 changes: 2 additions & 0 deletions includes/AutoLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,10 @@
'SearchResult' => 'includes/search/SearchEngine.php',
'SearchResultSet' => 'includes/search/SearchEngine.php',
'SearchResultTooMany' => 'includes/search/SearchEngine.php',
'SearchSqlite' => 'includes/search/SearchSqlite.php',
'SearchUpdate' => 'includes/search/SearchUpdate.php',
'SearchUpdateMyISAM' => 'includes/search/SearchUpdate.php',
'SqliteSearchResultSet' => 'includes/search/SearchSqlite.php',

# includes/specials
'SpecialAllmessages' => 'includes/specials/SpecialAllmessages.php',
Expand Down
22 changes: 18 additions & 4 deletions includes/db/DatabaseSqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ public static function generateFileName( $dir, $dbName ) {
return "$dir/$dbName.sqlite";
}

/**
* Returns version of currently supported SQLite fulltext search module or false if none present.
* @return String
*/
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 ) ) {
$this->query( "DROP TABLE IF EXISTS $table", __METHOD__ );
return 'FTS3';
}
return false;
}

/**
* SQLite doesn't allow buffered results or data seeking etc, so we'll use fetchAll as the result
*/
Expand Down Expand Up @@ -319,15 +333,15 @@ function unionQueries( $sqls, $all ) {
}

function wasDeadlock() {
return $this->lastErrno() == SQLITE_BUSY;
return $this->lastErrno() == 5; // SQLITE_BUSY
}

function wasErrorReissuable() {
return $this->lastErrno() == SQLITE_SCHEMA;
return $this->lastErrno() == 17; // SQLITE_SCHEMA;
}

function wasReadOnlyError() {
return $this->lastErrno() == SQLITE_READONLY;
return $this->lastErrno() == 8; // SQLITE_READONLY;
}

/**
Expand Down Expand Up @@ -460,7 +474,7 @@ public function setup_database() {
}

public function getSearchEngine() {
return "SearchEngineDummy";
return "SearchSqlite";
}

/**
Expand Down
Loading

0 comments on commit 798cfc5

Please sign in to comment.