From: Greg Sabino Mullane Date: Sun, 10 Feb 2008 15:48:06 +0000 (+0000) Subject: Make Postgres 8.3 compatible. X-Git-Tag: 1.31.0-rc.0~49528 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=fa02443300f1d0f5e36da9422bd6d712b6211269;p=lhc%2Fweb%2Fwiklou.git Make Postgres 8.3 compatible. --- 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)