From: Chad Horohoe Date: Fri, 28 Jan 2011 14:12:26 +0000 (+0000) Subject: Per comment on bug 26612, we should drop the pre-Postgres 8.3 support with the TSearc... X-Git-Tag: 1.31.0-rc.0~32327 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=bf3e2be8d590262a577c1192d6daa1744165f363;p=lhc%2Fweb%2Fwiklou.git Per comment on bug 26612, we should drop the pre-Postgres 8.3 support with the TSearch2 schema. This removes a bunch of back-compat code in the installer and search code. Minimum postgres version is now 8.3 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 7bcc54bddd..7d9af50333 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1180,8 +1180,6 @@ $wgSQLMode = ''; /** Mediawiki schema */ $wgDBmwschema = 'mediawiki'; -/** Tsearch2 schema */ -$wgDBts2schema = 'public'; /** To override default SQLite data directory ($docroot/../data) */ $wgSQLiteDataDir = ''; diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 151f632b15..6b453cd0aa 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -193,13 +193,12 @@ class DatabasePostgres extends DatabaseBase { $this->doQuery( "SET client_encoding='UTF8'" ); global $wgDBmwschema, $wgDBts2schema; - if ( isset( $wgDBmwschema ) && isset( $wgDBts2schema ) + if ( isset( $wgDBmwschema ) && $wgDBmwschema !== 'mediawiki' && preg_match( '/^\w+$/', $wgDBmwschema ) - && preg_match( '/^\w+$/', $wgDBts2schema ) ) { $safeschema = $this->addIdentifierQuotes( $wgDBmwschema ); - $this->doQuery( "SET search_path = $safeschema, $wgDBts2schema, public" ); + $this->doQuery( "SET search_path = $safeschema, public" ); } return $this->mConn; diff --git a/includes/installer/Installer.i18n.php b/includes/installer/Installer.i18n.php index 3074350901..d71a3224be 100644 --- a/includes/installer/Installer.i18n.php +++ b/includes/installer/Installer.i18n.php @@ -195,7 +195,6 @@ but it will not let you store characters above the [http://en.wikipedia.org/wiki 'config-mysql-old' => 'MySQL $1 or later is required, you have $2.', 'config-db-port' => 'Database port:', 'config-db-schema' => 'Schema for MediaWiki', - 'config-db-ts2-schema' => 'Schema for tsearch2', 'config-db-schema-help' => 'The above schemas are usually correct. Only change them if you know you need to.', 'config-sqlite-dir' => 'SQLite data directory:', @@ -242,8 +241,6 @@ Use only ASCII letters (a-z, A-Z), numbers (0-9), underscores (_) and hyphens (- Check the host, username and password below and try again.', 'config-invalid-schema' => 'Invalid schema for MediaWiki "$1". -Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).', - 'config-invalid-ts2schema' => 'Invalid schema for TSearch2 "$1". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).', 'config-postgres-old' => 'PostgreSQL $1 or later is required, you have $2.', 'config-sqlite-name-help' => 'Choose a name that identifies your wiki. @@ -450,9 +447,6 @@ Make sure that the user "$1" can write to the schema "$2".', 'config-install-pg-commit' => 'Committing changes', 'config-install-pg-plpgsql' => 'Checking for language PL/pgSQL', 'config-pg-no-plpgsql' => 'You need to install the language PL/pgSQL in the database $1', - 'config-install-pg-ts2' => 'Checking for tsearch2', - 'config-install-pg-ts2-failed' => "'''FAILED''' tsearch2 must be installed in the database $1. -Please read [$2 these instructions] or ask on #postgresql on irc.freenode.net", 'config-install-user' => 'Creating database user', 'config-install-user-failed' => 'Granting permission to user "$1" failed: $2', 'config-install-tables' => 'Creating tables', diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index 6202364d38..23a67b62a3 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -24,8 +24,7 @@ class PostgresInstaller extends DatabaseInstaller { 'wgDBts2schema', ); - var $minimumVersion = '8.1'; - private $ts2MaxVersion = '8.3'; // Doing ts2 is not necessary in PG > 8.3 + var $minimumVersion = '8.3'; function getName() { return 'postgres'; @@ -43,7 +42,6 @@ class PostgresInstaller extends DatabaseInstaller { Html::element( 'legend', array(), wfMsg( 'config-db-wiki-settings' ) ) . $this->getTextBox( 'wgDBname', 'config-db-name', array(), $this->parent->getHelpBox( 'config-db-name-help' ) ) . $this->getTextBox( 'wgDBmwschema', 'config-db-schema', array(), $this->parent->getHelpBox( 'config-db-schema-help' ) ) . - $this->getTextBox( 'wgDBts2schema', 'config-db-ts2-schema' ) . Html::closeElement( 'fieldset' ) . $this->getInstallUserBox(); } @@ -51,7 +49,7 @@ class PostgresInstaller extends DatabaseInstaller { function submitConnectForm() { // Get variables from the request $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBport', - 'wgDBname', 'wgDBmwschema', 'wgDBts2schema' ) ); + 'wgDBname', 'wgDBmwschema' ) ); // Validate them $status = Status::newGood(); @@ -63,9 +61,6 @@ class PostgresInstaller extends DatabaseInstaller { if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBmwschema'] ) ) { $status->fatal( 'config-invalid-schema', $newValues['wgDBmwschema'] ); } - if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBts2schema'] ) ) { - $status->fatal( 'config-invalid-ts2schema', $newValues['wgDBts2schema'] ); - } // Submit user box if ( $status->isOK() ) { @@ -196,17 +191,12 @@ class PostgresInstaller extends DatabaseInstaller { 'name' => 'user', 'callback' => array( $this, 'setupUser' ), ); - $ts2CB = array( - 'name' => 'pg-ts2', - 'callback' => array( $this, 'setupTs2' ), - ); $plpgCB = array( 'name' => 'pg-plpgsql', 'callback' => array( $this, 'setupPLpgSQL' ), ); $this->parent->addInstallStep( $commitCB, 'interwiki' ); $this->parent->addInstallStep( $userCB ); - $this->parent->addInstallStep( $ts2CB, 'database' ); $this->parent->addInstallStep( $plpgCB, 'database' ); } @@ -266,36 +256,6 @@ class PostgresInstaller extends DatabaseInstaller { return $status; } - /** - * Ts2 isn't needed in newer versions of Postgres, so wrap it in a nice big - * version check and skip it if we're new. Maybe we can bump $minimumVersion - * one day and render this obsolete :) - * - * @return Status - */ - function setupTs2() { - $status = $this->getConnection(); - if ( !$status->isOK() ) { - return $status; - } - - if( version_compare( $this->db->getServerVersion(), $this->ts2MaxVersion, '<' ) ) { - if ( !$this->db->tableExists( 'pg_ts_cfg', $this->getVar( 'wgDBts2schema' ) ) ) { - return Status::newFatal( - 'config-install-pg-ts2-failed', - $this->getVar( 'wgDBname' ), - 'http://www.devx.com/opensource/Article/21674/0/page/2' - ); - } - $safeuser = $this->db->addQuotes( $this->getVar( 'wgDBuser' ) ); - foreach ( array( 'cfg', 'cfgmap', 'dict', 'parser' ) as $table ) { - $sql = "GRANT SELECT ON pg_ts_$table TO $safeuser"; - $this->db->query( $sql, __METHOD__ ); - } - } - return Status::newGood(); - } - function commitChanges() { $this->db->query( 'COMMIT' ); return Status::newGood(); diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index 639d0a22d6..70997f34c8 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -141,13 +141,11 @@ class SearchPostgres extends SearchEngine { function searchQuery( $term, $fulltext, $colname ) { $postgresVersion = $this->db->getServerVersion(); - $prefix = $postgresVersion < 8.3 ? "'default'," : ''; - # Get the SQL fragment for the given term $searchstring = $this->parseQuery( $term ); ## We need a separate query here so gin does not complain about empty searches - $SQL = "SELECT to_tsquery($prefix $searchstring)"; + $SQL = "SELECT to_tsquery($searchstring)"; $res = $this->db->doQuery($SQL); if (!$res) { ## TODO: Better output (example to catch: one 'two) @@ -168,12 +166,10 @@ class SearchPostgres extends SearchEngine { } } - $rankscore = $postgresVersion > 8.2 ? 5 : 1; - $rank = $postgresVersion < 8.3 ? 'rank' : 'ts_rank'; $query = "SELECT page_id, page_namespace, page_title, ". - "$rank($fulltext, to_tsquery($prefix $searchstring), $rankscore) AS score ". + "ts_rank($fulltext, to_tsquery($searchstring), 5) 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($prefix $searchstring)"; + "AND r.rev_text_id = c.old_id AND $fulltext @@ to_tsquery($searchstring)"; } ## Redirects