* @return bool Success of insert operation. IGNORE always returns true.
*/
function insert( $table, $args, $fname = 'DatabasePostgres::insert', $options = array() ) {
- global $wgDBversion;
-
if ( !count( $args ) ) {
return true;
}
$table = $this->tableName( $table );
- if (! isset( $wgDBversion ) ) {
- $wgDBversion = $this->getServerVersion();
+ if (! isset( $this->numeric_version ) ) {
+ $this->getServerVersion();
}
if ( !is_array( $options ) )
$sql = "INSERT INTO $table (" . implode( ',', $keys ) . ') VALUES ';
if ( $multi ) {
- if ( $wgDBversion >= 8.2 && !$ignore ) {
+ if ( $this->numeric_version >= 8.2 && !$ignore ) {
$first = true;
foreach ( $args as $row ) {
if ( $first ) {
* @return string Version information from the database
*/
function getServerVersion() {
- $versionInfo = pg_version( $this->mConn );
- if ( version_compare( $versionInfo['client'], '7.4.0', 'lt' ) ) {
- // Old client, abort install
- $this->numeric_version = '7.3 or earlier';
- } elseif ( isset( $versionInfo['server'] ) ) {
- // Normal client
- $this->numeric_version = $versionInfo['server'];
- } else {
- // Bug 16937: broken pgsql extension from PHP<5.3
- $this->numeric_version = pg_parameter_status( $this->mConn, 'server_version' );
+ if ( ! isset( this->numeric_version ) ) {
+ $versionInfo = pg_version( $this->mConn );
+ if ( version_compare( $versionInfo['client'], '7.4.0', 'lt' ) ) {
+ // Old client, abort install
+ $this->numeric_version = '7.3 or earlier';
+ } elseif ( isset( $versionInfo['server'] ) ) {
+ // Normal client
+ $this->numeric_version = $versionInfo['server'];
+ } else {
+ // Bug 16937: broken pgsql extension from PHP<5.3
+ $this->numeric_version = pg_parameter_status( $this->mConn, 'server_version' );
+ }
}
return $this->numeric_version;
}
* @param $colname
*/
function searchQuery( $term, $fulltext, $colname ) {
- global $wgDBversion;
+ $postgresVersion = $this->db->getServerVersion();
- if ( !isset( $wgDBversion ) ) {
- $this->db->getServerVersion();
- $wgDBversion = $this->db->numeric_version;
- }
- $prefix = $wgDBversion < 8.3 ? "'default'," : '';
+ $prefix = $postgresVersion < 8.3 ? "'default'," : '';
# Get the SQL fragment for the given term
$searchstring = $this->parseQuery( $term );
}
}
- $rankscore = $wgDBversion > 8.2 ? 5 : 1;
- $rank = $wgDBversion < 8.3 ? 'rank' : 'ts_rank';
+ $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 ".
"FROM page p, revision r, pagecontent c WHERE p.page_latest = r.rev_id " .