From fa02443300f1d0f5e36da9422bd6d712b6211269 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Sun, 10 Feb 2008 15:48:06 +0000 Subject: [PATCH] Make Postgres 8.3 compatible. --- includes/SearchPostgres.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/includes/SearchPostgres.php b/includes/SearchPostgres.php index cf9e6981ae..8dd9406195 100644 --- a/includes/SearchPostgres.php +++ b/includes/SearchPostgres.php @@ -122,11 +122,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 +149,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::char'; ## IS FALSE ## Namespaces - defaults to 0 if ( count($this->namespaces) < 1) -- 2.20.1