Completed removal of $wgDBport_db2 in favour of regular $wgDBport begun by platonides...
authorLeons Petrazickis <leonsp@users.mediawiki.org>
Wed, 1 Sep 2010 21:06:42 +0000 (21:06 +0000)
committerLeons Petrazickis <leonsp@users.mediawiki.org>
Wed, 1 Sep 2010 21:06:42 +0000 (21:06 +0000)
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
includes/db/DatabaseIbm_db2.php
maintenance/ibm_db2/tables.sql

index 8c7c0e5..a421517 100644 (file)
@@ -644,9 +644,6 @@ print "<li style='font-weight:bold;color:green;font-size:110%'>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 ) ) {
        
        <?php database_switcher($ourdb, 'ibm_db2'); ?>
        <div class="config-input"><?php
-               aField( $conf, "DBport_db2", "Database port:" );
+               aField( $conf, "DBport", "Database port:" );
        ?></div>
+       <div class="config-desc">
+               <p>50000 is the usual DB2 port.</p>
+       </div>
        <div class="config-input"><?php
                aField( $conf, "DBdb2schema", "Schema for mediawiki:" );
        ?></div>
-       <div>Select one:</div>
-               <ul class="plain">
-               <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
-               <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
-               </ul>
        <div class="config-desc">
                <p>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
index 550b6e5..047134e 100644 (file)
@@ -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 "<li>$string</li>";
+                       print "<li><pre>$string</pre></li>";
                        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;
        }
 
index 1e1e9aa..546c871 100644 (file)
@@ -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 (