From 76e28120a75aa14b7430367f57dc3c7586c08518 Mon Sep 17 00:00:00 2001 From: Leons Petrazickis Date: Wed, 1 Sep 2010 21:06:42 +0000 Subject: [PATCH] Completed removal of $wgDBport_db2 in favour of regular $wgDBport begun by platonides in r69918. Removed $wgDBcataloged based on discussion with platonides for r45755. All DB2 connections are now uncataloged. There is no performance difference. Now using DB2 persistent connections. Removed uniqueness constraint on user_groups table index in DB2 schema. --- config/Installer.php | 19 +++++---------- includes/db/DatabaseIbm_db2.php | 41 +++++++++++---------------------- maintenance/ibm_db2/tables.sql | 6 +---- 3 files changed, 21 insertions(+), 45 deletions(-) diff --git a/config/Installer.php b/config/Installer.php index 8c7c0e5fa6..a421517d5e 100644 --- a/config/Installer.php +++ b/config/Installer.php @@ -644,9 +644,6 @@ print "
  • Environment check $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "$IP/../data" ); ## DB2 specific: - // New variable in order to have a different default port number - $conf->DBport_db2 = importPost( "DBport_db2", "50000" ); - $conf->DBcataloged = importPost( "DBcataloged", "cataloged" ); $conf->DBdb2schema = importPost( "DBdb2schema", "mediawiki" ); // Oracle specific @@ -837,7 +834,6 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { } ## DB2 specific: - $wgDBcataloged = $conf->DBcataloged; $wgCommandLineMode = true; if (! defined ( 'STDERR' ) ) @@ -1711,16 +1707,14 @@ if( count( $errs ) ) {
    +
    +

    50000 is the usual DB2 port.

    +
    -
    Select one:
    -

    If you need to share one database between multiple wikis, or between MediaWiki and another web application, you may specify @@ -1913,9 +1907,8 @@ function writeLocalSettings( $conf ) { } elseif( $conf->DBtype == 'ibm_db2' ) { $dbsettings = "# DB2 specific settings -\$wgDBport = \"{$slconf['DBport_db2']}\"; -\$wgDBmwschema = \"{$slconf['DBdb2schema']}\"; -\$wgDBcataloged = \"{$slconf['DBcataloged']}\";"; +\$wgDBport = \"{$slconf['DBport']}\"; +\$wgDBmwschema = \"{$slconf['DBdb2schema']}\";"; } elseif( $conf->DBtype == 'oracle' ) { $dbsettings = "# Oracle specific settings diff --git a/includes/db/DatabaseIbm_db2.php b/includes/db/DatabaseIbm_db2.php index 550b6e5416..047134e2e9 100644 --- a/includes/db/DatabaseIbm_db2.php +++ b/includes/db/DatabaseIbm_db2.php @@ -122,10 +122,8 @@ class DatabaseIbm_db2 extends DatabaseBase { * */ - /// Server port for uncataloged connections + /// Server port protected $mPort = null; - /// Whether connection is cataloged - protected $mCataloged = null; /// Schema for tables, stored procedures, triggers protected $mSchema = null; /// Whether the schema has been applied in this session @@ -143,8 +141,6 @@ class DatabaseIbm_db2 extends DatabaseBase { public $mStmtOptions = array(); - const CATALOGED = "cataloged"; - const UNCATALOGED = "uncataloged"; const USE_GLOBAL = "get from global"; const NONE_OPTION = 0x00; @@ -461,7 +457,7 @@ class DatabaseIbm_db2 extends DatabaseBase { private function installPrint($string) { wfDebug("$string\n"); if ($this->mMode == self::INSTALL_MODE) { - print "

  • $string
  • "; + print "
  • $string
  • "; flush(); } } @@ -478,7 +474,7 @@ class DatabaseIbm_db2 extends DatabaseBase { public function open( $server, $user, $password, $dbName ) { // Load the port number - global $wgDBport, $wgDBcataloged; + global $wgDBport; wfProfileIn( __METHOD__ ); // Load IBM DB2 driver if missing @@ -503,14 +499,9 @@ class DatabaseIbm_db2 extends DatabaseBase { $this->mUser = $user; $this->mPassword = $password; $this->mDBname = $dbName; - $this->mCataloged = $cataloged = $wgDBcataloged; - if ( $cataloged == self::CATALOGED ) { - $this->openCataloged($dbName, $user, $password); - } - elseif ( $cataloged == self::UNCATALOGED ) { - $this->openUncataloged($dbName, $user, $password, $server, $port); - } + $this->openUncataloged($dbName, $user, $password, $server, $port); + // Apply connection config db2_set_option($this->mConn, $this->mConnOptions, 1); // Not all MediaWiki code is transactional @@ -536,7 +527,7 @@ class DatabaseIbm_db2 extends DatabaseBase { */ protected function openCataloged( $dbName, $user, $password ) { - @$this->mConn = db2_connect($dbName, $user, $password); + @$this->mConn = db2_pconnect($dbName, $user, $password); } /** @@ -552,7 +543,7 @@ class DatabaseIbm_db2 extends DatabaseBase { $str .= "UID=$user;"; $str .= "PWD=$password;"; - @$this->mConn = db2_connect($str, $user, $password); + @$this->mConn = db2_pconnect($str, $user, $password); } /** @@ -902,11 +893,11 @@ EOF; $list .= ", $field = ?"; } else { - $list .= "( $field = ?"; + $list .= "$field = ?"; $first = false; } } - $list .= ')'; + $list .= ''; return $list; } @@ -1473,15 +1464,8 @@ EOF; // db2_ping() doesn't exist // Emulate $this->close(); - if ($this->mCataloged == null) { - return false; - } - else if ($this->mCataloged) { - $this->mConn = $this->openCataloged($this->mDBName, $this->mUser, $this->mPassword); - } - else if (!$this->mCataloged) { - $this->mConn = $this->openUncataloged($this->mDBName, $this->mUser, $this->mPassword, $this->mServer, $this->mPort); - } + $this->mConn = $this->openUncataloged($this->mDBName, $this->mUser, $this->mPassword, $this->mServer, $this->mPort); + return false; } ###################################### @@ -1706,6 +1690,9 @@ SQL; array_shift( $args ); } $res = db2_execute($prepared, $args); + if ( !$res ) { + $this->installPrint(db2_stmt_errormsg()); + } return $res; } diff --git a/maintenance/ibm_db2/tables.sql b/maintenance/ibm_db2/tables.sql index 1e1e9aa776..546c871d41 100644 --- a/maintenance/ibm_db2/tables.sql +++ b/maintenance/ibm_db2/tables.sql @@ -48,11 +48,7 @@ CREATE TABLE user_groups ( -- REFERENCES user(user_id) ON DELETE CASCADE, ug_group VARCHAR(255) NOT NULL ); -CREATE UNIQUE INDEX user_groups_unique ON user_groups (ug_user, ug_group); ---leonsp: -CREATE UNIQUE INDEX user_groups_include_idx - ON user_groups(ug_user) - INCLUDE (ug_group); +CREATE INDEX user_groups_unique ON user_groups (ug_user, ug_group); CREATE TABLE user_newtalk ( -- 2.20.1