r72166 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72165‎ | r72166 | r72167 >
Date:21:06, 1 September 2010
Author:leonsp
Status:deferred (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/config/Installer.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseIbm_db2.php (modified) (history)
  • /trunk/phase3/maintenance/ibm_db2/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/ibm_db2/tables.sql
@@ -48,11 +48,7 @@
4949 -- REFERENCES user(user_id) ON DELETE CASCADE,
5050 ug_group VARCHAR(255) NOT NULL
5151 );
52 -CREATE UNIQUE INDEX user_groups_unique ON user_groups (ug_user, ug_group);
53 -CREATE UNIQUE INDEX user_groups_include_idx
54 - ON user_groups(ug_user)
55 - INCLUDE (ug_group);
 52+CREATE INDEX user_groups_unique ON user_groups (ug_user, ug_group);
5653
5754
5855 CREATE TABLE user_newtalk (
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php
@@ -122,10 +122,8 @@
123123 *
124124 */
125125
126 - /// Server port for uncataloged connections
 126+ /// Server port
127127 protected $mPort = null;
128 - /// Whether connection is cataloged
129 - protected $mCataloged = null;
130128 /// Schema for tables, stored procedures, triggers
131129 protected $mSchema = null;
132130 /// Whether the schema has been applied in this session
@@ -143,8 +141,6 @@
144142 public $mStmtOptions = array();
145143
146144
147 - const CATALOGED = "cataloged";
148 - const UNCATALOGED = "uncataloged";
149145 const USE_GLOBAL = "get from global";
150146
151147 const NONE_OPTION = 0x00;
@@ -461,7 +457,7 @@
462458 private function installPrint($string) {
463459 wfDebug("$string\n");
464460 if ($this->mMode == self::INSTALL_MODE) {
465 - print "<li>$string</li>";
 461+ print "<li><pre>$string</pre></li>";
466462 flush();
467463 }
468464 }
@@ -478,7 +474,7 @@
479475 public function open( $server, $user, $password, $dbName )
480476 {
481477 // Load the port number
482 - global $wgDBport, $wgDBcataloged;
 478+ global $wgDBport;
483479 wfProfileIn( __METHOD__ );
484480
485481 // Load IBM DB2 driver if missing
@@ -503,14 +499,9 @@
504500 $this->mUser = $user;
505501 $this->mPassword = $password;
506502 $this->mDBname = $dbName;
507 - $this->mCataloged = $cataloged = $wgDBcataloged;
508503
509 - if ( $cataloged == self::CATALOGED ) {
510 - $this->openCataloged($dbName, $user, $password);
511 - }
512 - elseif ( $cataloged == self::UNCATALOGED ) {
513 - $this->openUncataloged($dbName, $user, $password, $server, $port);
514 - }
 504+ $this->openUncataloged($dbName, $user, $password, $server, $port);
 505+
515506 // Apply connection config
516507 db2_set_option($this->mConn, $this->mConnOptions, 1);
517508 // Not all MediaWiki code is transactional
@@ -536,7 +527,7 @@
537528 */
538529 protected function openCataloged( $dbName, $user, $password )
539530 {
540 - @$this->mConn = db2_connect($dbName, $user, $password);
 531+ @$this->mConn = db2_pconnect($dbName, $user, $password);
541532 }
542533
543534 /**
@@ -552,7 +543,7 @@
553544 $str .= "UID=$user;";
554545 $str .= "PWD=$password;";
555546
556 - @$this->mConn = db2_connect($str, $user, $password);
 547+ @$this->mConn = db2_pconnect($str, $user, $password);
557548 }
558549
559550 /**
@@ -902,11 +893,11 @@
903894 $list .= ", $field = ?";
904895 }
905896 else {
906 - $list .= "( $field = ?";
 897+ $list .= "$field = ?";
907898 $first = false;
908899 }
909900 }
910 - $list .= ')';
 901+ $list .= '';
911902
912903 return $list;
913904 }
@@ -1473,15 +1464,8 @@
14741465 // db2_ping() doesn't exist
14751466 // Emulate
14761467 $this->close();
1477 - if ($this->mCataloged == null) {
1478 - return false;
1479 - }
1480 - else if ($this->mCataloged) {
1481 - $this->mConn = $this->openCataloged($this->mDBName, $this->mUser, $this->mPassword);
1482 - }
1483 - else if (!$this->mCataloged) {
1484 - $this->mConn = $this->openUncataloged($this->mDBName, $this->mUser, $this->mPassword, $this->mServer, $this->mPort);
1485 - }
 1468+ $this->mConn = $this->openUncataloged($this->mDBName, $this->mUser, $this->mPassword, $this->mServer, $this->mPort);
 1469+
14861470 return false;
14871471 }
14881472 ######################################
@@ -1706,6 +1690,9 @@
17071691 array_shift( $args );
17081692 }
17091693 $res = db2_execute($prepared, $args);
 1694+ if ( !$res ) {
 1695+ $this->installPrint(db2_stmt_errormsg());
 1696+ }
17101697 return $res;
17111698 }
17121699
Index: trunk/phase3/config/Installer.php
@@ -644,9 +644,6 @@
645645 $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "$IP/../data" );
646646
647647 ## DB2 specific:
648 - // New variable in order to have a different default port number
649 - $conf->DBport_db2 = importPost( "DBport_db2", "50000" );
650 - $conf->DBcataloged = importPost( "DBcataloged", "cataloged" );
651648 $conf->DBdb2schema = importPost( "DBdb2schema", "mediawiki" );
652649
653650 // Oracle specific
@@ -837,7 +834,6 @@
838835 }
839836
840837 ## DB2 specific:
841 - $wgDBcataloged = $conf->DBcataloged;
842838
843839 $wgCommandLineMode = true;
844840 if (! defined ( 'STDERR' ) )
@@ -1711,16 +1707,14 @@
17121708
17131709 <?php database_switcher($ourdb, 'ibm_db2'); ?>
17141710 <div class="config-input"><?php
1715 - aField( $conf, "DBport_db2", "Database port:" );
 1711+ aField( $conf, "DBport", "Database port:" );
17161712 ?></div>
 1713+ <div class="config-desc">
 1714+ <p>50000 is the usual DB2 port.</p>
 1715+ </div>
17171716 <div class="config-input"><?php
17181717 aField( $conf, "DBdb2schema", "Schema for mediawiki:" );
17191718 ?></div>
1720 - <div>Select one:</div>
1721 - <ul class="plain">
1722 - <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 installed locally)", "radio", "cataloged" ); ?></li>
1723 - <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
1724 - </ul>
17251719 <div class="config-desc">
17261720 <p>If you need to share one database between multiple wikis, or
17271721 between MediaWiki and another web application, you may specify
@@ -1913,9 +1907,8 @@
19141908 } elseif( $conf->DBtype == 'ibm_db2' ) {
19151909 $dbsettings =
19161910 "# DB2 specific settings
1917 -\$wgDBport = \"{$slconf['DBport_db2']}\";
1918 -\$wgDBmwschema = \"{$slconf['DBdb2schema']}\";
1919 -\$wgDBcataloged = \"{$slconf['DBcataloged']}\";";
 1911+\$wgDBport = \"{$slconf['DBport']}\";
 1912+\$wgDBmwschema = \"{$slconf['DBdb2schema']}\";";
19201913 } elseif( $conf->DBtype == 'oracle' ) {
19211914 $dbsettings =
19221915 "# Oracle specific settings

Follow-up revisions

RevisionCommit summaryAuthorDate
r72171Reverting some of r72166 and fixing the $wgDBport collision between Postgres ...leonsp22:37, 1 September 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45755(bug 17028) Added support for IBM DB2 database. config/index.php has new inte...leonsp22:20, 14 January 2009
r69918Kill $wgDBport_db2platonides21:43, 25 July 2010

Comments

#Comment by Platonides (talk | contribs)   21:50, 1 September 2010
-		aField( $conf, "DBport_db2", "Database port:" );
+		aField( $conf, "DBport", "Database port:" );

This makes two databases (Postgres and db2) using the same field name (DBport) which makes only the last one to be used (there was a bug in bugzilla about the same which happened with mysql and postgres).

#Comment by Leonsp (talk | contribs)   21:53, 1 September 2010

Hmm. The problem I was trying to fix with this is that I was getting port 5244 while submitting port 50000 in the form. I'll take another look.

#Comment by Platonides (talk | contribs)   21:54, 1 September 2010

With this change you will likely be using port 50000 for postgres users instead of 5432 (i think latest wins).

I don't see where the 5244 comes from, though.

Status & tagging log