r81084 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81083‎ | r81084 | r81085 >
Date:08:25, 27 January 2011
Author:tstarling
Status:ok
Tags:
Comment:
* Fixed Oracle new installer support, broken by r80957. This is a minimal patch and doesn't address the architectural issues.
** Moved the responsibility for calling setupSchemaVars() on install to the DatabaseInstaller subclass. This allows it to be called after setupDatabase() has completed, as required by Oracle and PostgreSQL.
** Fixed OracleInstaller::getConnection() so that it respects $this->useSysDBA correctly.
** In OracleInstaller, added some more variables to the list of schema vars, which are needed by user.sql and tables.sql
** In SearchOracle, specify the database name when calling ctx_ddl.sync_index(). This fixes a fatal error in the createMainpage step, caused by the schema name not being equal to the current user.

* In oracle/tables.sql, fixed a couple of indexes with missing table prefixes.
* Improved debugging output in DatabaseInstaller::getConnection() and Installer::createMainpage().
* In DatabaseBase::selectDB(), set $this->mDBname correctly, as in DatabaseMysql.
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/includes/installer/DatabaseInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/OracleInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/SqliteInstaller.php (modified) (history)
  • /trunk/phase3/includes/search/SearchOracle.php (modified) (history)
  • /trunk/phase3/maintenance/oracle/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/oracle/tables.sql
@@ -610,8 +610,8 @@
611611 --);
612612 --CREATE UNIQUE INDEX &mw_prefix.profiling_u01 ON &mw_prefix.profiling (pf_name, pf_server);
613613
614 -CREATE INDEX si_title_idx ON &mw_prefix.searchindex(si_title) INDEXTYPE IS ctxsys.context;
615 -CREATE INDEX si_text_idx ON &mw_prefix.searchindex(si_text) INDEXTYPE IS ctxsys.context;
 614+CREATE INDEX &mw_prefix.si_title_idx ON &mw_prefix.searchindex(si_title) INDEXTYPE IS ctxsys.context;
 615+CREATE INDEX &mw_prefix.si_text_idx ON &mw_prefix.searchindex(si_text) INDEXTYPE IS ctxsys.context;
616616
617617 CREATE TABLE &mw_prefix.l10n_cache (
618618 lc_lang varchar2(32) NOT NULL,
Index: trunk/phase3/includes/search/SearchOracle.php
@@ -246,8 +246,16 @@
247247 'si_title' => $title,
248248 'si_text' => $text
249249 ), 'SearchOracle::update' );
250 - $dbw->query("CALL ctx_ddl.sync_index('si_text_idx')");
251 - $dbw->query("CALL ctx_ddl.sync_index('si_title_idx')");
 250+
 251+ // Sync the index
 252+ // We need to specify the DB name (i.e. user/schema) here so that
 253+ // it can work from the installer, where
 254+ // ALTER SESSION SET CURRENT_SCHEMA = ...
 255+ // was used.
 256+ $dbw->query( "CALL ctx_ddl.sync_index(" .
 257+ $dbw->addQuotes( $dbw->getDBname() . '.si_text_idx' ) . ")" );
 258+ $dbw->query( "CALL ctx_ddl.sync_index(" .
 259+ $dbw->addQuotes( $dbw->getDBname() . '.si_title_idx' ) . ")" );
252260 }
253261
254262 /**
Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -1086,10 +1086,16 @@
10871087 }
10881088
10891089 function selectDB( $db ) {
1090 - if ( $db == null || $db == $this->mUser ) { return true; }
 1090+ $this->mDBname = $db;
 1091+ if ( $db == null || $db == $this->mUser ) {
 1092+ return true;
 1093+ }
10911094 $sql = 'ALTER SESSION SET CURRENT_SCHEMA=' . strtoupper($db);
10921095 $stmt = oci_parse( $this->mConn, $sql );
1093 - if ( !oci_execute( $stmt ) ) {
 1096+ wfSuppressWarnings();
 1097+ $success = oci_execute( $stmt );
 1098+ wfRestoreWarnings();
 1099+ if ( !$success ) {
10941100 $e = oci_error( $stmt );
10951101 if ( $e['code'] != '1435' ) {
10961102 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
Index: trunk/phase3/includes/db/Database.php
@@ -1474,6 +1474,7 @@
14751475 # Stub. Shouldn't cause serious problems if it's not overridden, but
14761476 # if your database engine supports a concept similar to MySQL's
14771477 # databases you may as well.
 1478+ $this->mDBname = $db;
14781479 return true;
14791480 }
14801481
Index: trunk/phase3/includes/installer/Installer.php
@@ -1272,7 +1272,6 @@
12731273 $installResults = array();
12741274 $installer = $this->getDBInstaller();
12751275 $installer->preInstall();
1276 - $installer->setupSchemaVars();
12771276 $steps = $this->getInstallSteps( $installer );
12781277 foreach( $steps as $stepObj ) {
12791278 $name = $stepObj['name'];
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -471,7 +471,7 @@
472472 'config-install-sysop' => 'Creating administrator user account',
473473 'config-install-subscribe-fail' => 'Unable to subscribe to mediawiki-announce',
474474 'config-install-mainpage' => 'Creating main page with default content',
475 - 'config-install-mainpage-failed' => 'Could not insert main page.',
 475+ 'config-install-mainpage-failed' => 'Could not insert main page: $1',
476476 'config-install-done' => "'''Congratulations!'''
477477 You have successfully installed MediaWiki.
478478
Index: trunk/phase3/includes/installer/SqliteInstaller.php
@@ -144,6 +144,7 @@
145145 $this->setVar( 'wgDBserver', '' );
146146 $this->setVar( 'wgDBuser', '' );
147147 $this->setVar( 'wgDBpassword', '' );
 148+ $this->setupSchemaVars();
148149 return $this->getConnection();
149150 }
150151
Index: trunk/phase3/includes/installer/DatabaseInstaller.php
@@ -195,6 +195,8 @@
196196 $status = $this->getConnection();
197197 if ( $status->isOK() ) {
198198 $status->value->setSchemaVars( $this->getSchemaVars() );
 199+ } else {
 200+ throw new MWException( __METHOD__.': unexpected DB connection error' );
199201 }
200202 }
201203
Index: trunk/phase3/includes/installer/MysqlInstaller.php
@@ -414,6 +414,7 @@
415415 $conn->query( "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ), __METHOD__ );
416416 $conn->selectDB( $dbName );
417417 }
 418+ $this->setupSchemaVars();
418419 return $status;
419420 }
420421
Index: trunk/phase3/includes/installer/OracleInstaller.php
@@ -31,6 +31,8 @@
3232
3333 public $minimumVersion = '9.0.1'; // 9iR1
3434
 35+ protected $sysConn, $userConn;
 36+
3537 public function getName() {
3638 return 'oracle';
3739 }
@@ -117,7 +119,7 @@
118120 $this->getVar( 'wgDBserver' ),
119121 $this->getVar( '_InstallUser' ),
120122 $this->getVar( '_InstallPassword' ),
121 - $this->getVar( 'wgDBname' ),
 123+ $this->getVar( '_InstallUser' ),
122124 DBO_SYSDBA | DBO_DDLMODE,
123125 $this->getVar( 'wgDBprefix' )
124126 );
@@ -138,6 +140,42 @@
139141 return $status;
140142 }
141143
 144+ /**
 145+ * Cache the two different types of connection which can be returned by
 146+ * openConnection().
 147+ *
 148+ * $this->db will be set to the last used connection object.
 149+ *
 150+ * FIXME: openConnection() should not be doing two different things.
 151+ */
 152+ public function getConnection() {
 153+ // Check cache
 154+ if ( $this->useSysDBA ) {
 155+ $conn = $this->sysConn;
 156+ } else {
 157+ $conn = $this->userConn;
 158+ }
 159+ if ( $conn !== null ) {
 160+ $this->db = $conn;
 161+ return Status::newGood( $conn );
 162+ }
 163+
 164+ // Open a new connection
 165+ $status = $this->openConnection();
 166+ if ( !$status->isOK() ) {
 167+ return $status;
 168+ }
 169+
 170+ // Save to the cache
 171+ if ( $this->useSysDBA ) {
 172+ $this->sysConn = $status->value;
 173+ } else {
 174+ $this->userConn = $status->value;
 175+ }
 176+ $this->db = $status->value;
 177+ return $status;
 178+ }
 179+
142180 public function needsUpgrade() {
143181 $tempDBname = $this->getVar( 'wgDBname' );
144182 $this->parent->setVar( 'wgDBname', $this->getVar( 'wgDBuser' ) );
@@ -175,6 +213,8 @@
176214 return $status;
177215 }
178216
 217+ $this->setupSchemaVars();
 218+
179219 if ( !$this->db->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
180220 $this->db->setFlag( DBO_DDLMODE );
181221 $error = $this->db->sourceFile( "$IP/maintenance/oracle/user.sql" );
@@ -183,6 +223,7 @@
184224 }
185225 }
186226
 227+
187228 return $status;
188229 }
189230
@@ -190,6 +231,8 @@
191232 * Overload: after this action field info table has to be rebuilt
192233 */
193234 public function createTables() {
 235+ $this->setupSchemaVars();
 236+ $this->db->selectDB( $this->getVar( 'wgDBuser' ) );
194237 $status = parent::createTables();
195238
196239 $this->db->query( 'BEGIN fill_wiki_info; END;' );
@@ -198,13 +241,21 @@
199242 }
200243
201244 public function getSchemaVars() {
202 - /**
203 - * The variables $_OracleDefTS, $_OracleTempTS are used by maintenance/oracle/user.sql
204 - */
205 - return array(
206 - '_OracleDefTS' => $this->getVar( '_OracleDefTS' ),
207 - '_OracleTempTS' => $this->getVar( '_OracleTempTS' ),
 245+ $varNames = array(
 246+ # These variables are used by maintenance/oracle/user.sql
 247+ '_OracleDefTS',
 248+ '_OracleTempTS',
 249+ 'wgDBuser',
 250+ 'wgDBpassword',
 251+
 252+ # These are used by tables.sql
 253+ 'wgDBprefix',
208254 );
 255+ $vars = array();
 256+ foreach ( $varNames as $name ) {
 257+ $vars[$name] = $this->getVar( $name );
 258+ }
 259+ return $vars;
209260 }
210261
211262 public function getLocalSettings() {
Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -215,6 +215,7 @@
216216 if ( !$status->isOK() ) {
217217 return $status;
218218 }
 219+ $this->setupSchemaVars();
219220 $conn = $status->value;
220221
221222 $dbName = $this->getVar( 'wgDBname' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r82439Bug 27053 - sourceFile() didn't expand all the required variables. Apparently...maxsem08:01, 19 February 2011
r85669* r81084 added prefix to index name and as this index gets synced directly it...freakolowsky12:45, 8 April 2011
r85670* partial merge of r81084 (installer and search was broken)...freakolowsky13:25, 8 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80957* Fixed a bug causing the installer to ignore the "engine" and "charset" sett...tstarling07:37, 25 January 2011

Status & tagging log