summaryrefslogtreecommitdiff
path: root/includes/SearchPostgres.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2008-03-21 11:49:34 +0100
committerPierre Schmitz <pierre@archlinux.de>2008-03-21 11:49:34 +0100
commit086ae52d12011746a75f5588e877347bc0457352 (patch)
treee73263c7a29d0f94fafb874562610e16eb292ba8 /includes/SearchPostgres.php
parent749e7fb2bae7bbda855de3c9e319435b9f698ff7 (diff)
Update auf MediaWiki 1.12.0
Diffstat (limited to 'includes/SearchPostgres.php')
-rw-r--r--includes/SearchPostgres.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/includes/SearchPostgres.php b/includes/SearchPostgres.php
index cf9e6981..59110a5a 100644
--- a/includes/SearchPostgres.php
+++ b/includes/SearchPostgres.php
@@ -37,11 +37,24 @@ class SearchPostgres extends SearchEngine {
* @access public
*/
function searchTitle( $term ) {
- $resultSet = $this->db->resultObject( $this->db->query( $this->searchQuery( $term , 'titlevector', 'page_title' )));
+ $q = $this->searchQuery( $term , 'titlevector', 'page_title' );
+ $olderror = error_reporting(E_ERROR);
+ $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) );
+ error_reporting($olderror);
+ if (!$resultSet) {
+ // Needed for "Query requires full scan, GIN doesn't support it"
+ return new SearchResultTooMany();
+ }
return new PostgresSearchResultSet( $resultSet, $this->searchTerms );
}
function searchText( $term ) {
- $resultSet = $this->db->resultObject( $this->db->query( $this->searchQuery( $term, 'textvector', 'old_text' )));
+ $q = $this->searchQuery( $term, 'textvector', 'old_text' );
+ $olderror = error_reporting(E_ERROR);
+ $resultSet = $this->db->resultObject( $this->db->query( $q, 'SearchPostgres', true ) );
+ error_reporting($olderror);
+ if (!$resultSet) {
+ return new SearchResultTooMany();
+ }
return new PostgresSearchResultSet( $resultSet, $this->searchTerms );
}
@@ -122,11 +135,12 @@ class SearchPostgres extends SearchEngine {
$this->db->getServerVersion();
$wgDBversion = $this->db->numeric_version;
}
+ $prefix = $wgDBversion < 8.3 ? "'default'," : '';
$searchstring = $this->parseQuery( $term );
## We need a separate query here so gin does not complain about empty searches
- $SQL = "SELECT to_tsquery('default',$searchstring)";
+ $SQL = "SELECT to_tsquery($prefix $searchstring)";
$res = $this->db->doQuery($SQL);
if (!$res) {
## TODO: Better output (example to catch: one 'two)
@@ -148,15 +162,16 @@ class SearchPostgres extends SearchEngine {
}
$rankscore = $wgDBversion > 8.2 ? 5 : 1;
+ $rank = $wgDBversion < 8.3 ? 'rank' : 'ts_rank';
$query = "SELECT page_id, page_namespace, page_title, ".
- "rank($fulltext, to_tsquery('default',$searchstring), $rankscore) AS score ".
+ "$rank($fulltext, to_tsquery($prefix $searchstring), $rankscore) AS score ".
"FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .
- "AND r.rev_text_id = c.old_id AND $fulltext @@ to_tsquery('default',$searchstring)";
+ "AND r.rev_text_id = c.old_id AND $fulltext @@ to_tsquery($prefix $searchstring)";
}
## Redirects
if (! $this->showRedirects)
- $query .= ' AND page_is_redirect = 0'; ## IS FALSE
+ $query .= ' AND page_is_redirect = 0';
## Namespaces - defaults to 0
if ( count($this->namespaces) < 1)