* 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.
This commit is contained in:
parent
12c87d042c
commit
e1c8e80297
11 changed files with 85 additions and 15 deletions
|
|
@ -1474,6 +1474,7 @@ abstract class DatabaseBase implements DatabaseType {
|
|||
# Stub. Shouldn't cause serious problems if it's not overridden, but
|
||||
# if your database engine supports a concept similar to MySQL's
|
||||
# databases you may as well.
|
||||
$this->mDBname = $db;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1086,10 +1086,16 @@ class DatabaseOracle extends DatabaseBase {
|
|||
}
|
||||
|
||||
function selectDB( $db ) {
|
||||
if ( $db == null || $db == $this->mUser ) { return true; }
|
||||
$this->mDBname = $db;
|
||||
if ( $db == null || $db == $this->mUser ) {
|
||||
return true;
|
||||
}
|
||||
$sql = 'ALTER SESSION SET CURRENT_SCHEMA=' . strtoupper($db);
|
||||
$stmt = oci_parse( $this->mConn, $sql );
|
||||
if ( !oci_execute( $stmt ) ) {
|
||||
wfSuppressWarnings();
|
||||
$success = oci_execute( $stmt );
|
||||
wfRestoreWarnings();
|
||||
if ( !$success ) {
|
||||
$e = oci_error( $stmt );
|
||||
if ( $e['code'] != '1435' ) {
|
||||
$this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
|
||||
|
|
|
|||
|
|
@ -195,6 +195,8 @@ abstract class DatabaseInstaller {
|
|||
$status = $this->getConnection();
|
||||
if ( $status->isOK() ) {
|
||||
$status->value->setSchemaVars( $this->getSchemaVars() );
|
||||
} else {
|
||||
throw new MWException( __METHOD__.': unexpected DB connection error' );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@ Consider changing it manually.",
|
|||
'config-install-sysop' => 'Creating administrator user account',
|
||||
'config-install-subscribe-fail' => 'Unable to subscribe to mediawiki-announce',
|
||||
'config-install-mainpage' => 'Creating main page with default content',
|
||||
'config-install-mainpage-failed' => 'Could not insert main page.',
|
||||
'config-install-mainpage-failed' => 'Could not insert main page: $1',
|
||||
'config-install-done' => "'''Congratulations!'''
|
||||
You have successfully installed MediaWiki.
|
||||
|
||||
|
|
|
|||
|
|
@ -1272,7 +1272,6 @@ abstract class Installer {
|
|||
$installResults = array();
|
||||
$installer = $this->getDBInstaller();
|
||||
$installer->preInstall();
|
||||
$installer->setupSchemaVars();
|
||||
$steps = $this->getInstallSteps( $installer );
|
||||
foreach( $steps as $stepObj ) {
|
||||
$name = $stepObj['name'];
|
||||
|
|
|
|||
|
|
@ -414,6 +414,7 @@ class MysqlInstaller extends DatabaseInstaller {
|
|||
$conn->query( "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ), __METHOD__ );
|
||||
$conn->selectDB( $dbName );
|
||||
}
|
||||
$this->setupSchemaVars();
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ class OracleInstaller extends DatabaseInstaller {
|
|||
|
||||
public $minimumVersion = '9.0.1'; // 9iR1
|
||||
|
||||
protected $sysConn, $userConn;
|
||||
|
||||
public function getName() {
|
||||
return 'oracle';
|
||||
}
|
||||
|
|
@ -117,7 +119,7 @@ class OracleInstaller extends DatabaseInstaller {
|
|||
$this->getVar( 'wgDBserver' ),
|
||||
$this->getVar( '_InstallUser' ),
|
||||
$this->getVar( '_InstallPassword' ),
|
||||
$this->getVar( 'wgDBname' ),
|
||||
$this->getVar( '_InstallUser' ),
|
||||
DBO_SYSDBA | DBO_DDLMODE,
|
||||
$this->getVar( 'wgDBprefix' )
|
||||
);
|
||||
|
|
@ -138,6 +140,42 @@ class OracleInstaller extends DatabaseInstaller {
|
|||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache the two different types of connection which can be returned by
|
||||
* openConnection().
|
||||
*
|
||||
* $this->db will be set to the last used connection object.
|
||||
*
|
||||
* FIXME: openConnection() should not be doing two different things.
|
||||
*/
|
||||
public function getConnection() {
|
||||
// Check cache
|
||||
if ( $this->useSysDBA ) {
|
||||
$conn = $this->sysConn;
|
||||
} else {
|
||||
$conn = $this->userConn;
|
||||
}
|
||||
if ( $conn !== null ) {
|
||||
$this->db = $conn;
|
||||
return Status::newGood( $conn );
|
||||
}
|
||||
|
||||
// Open a new connection
|
||||
$status = $this->openConnection();
|
||||
if ( !$status->isOK() ) {
|
||||
return $status;
|
||||
}
|
||||
|
||||
// Save to the cache
|
||||
if ( $this->useSysDBA ) {
|
||||
$this->sysConn = $status->value;
|
||||
} else {
|
||||
$this->userConn = $status->value;
|
||||
}
|
||||
$this->db = $status->value;
|
||||
return $status;
|
||||
}
|
||||
|
||||
public function needsUpgrade() {
|
||||
$tempDBname = $this->getVar( 'wgDBname' );
|
||||
$this->parent->setVar( 'wgDBname', $this->getVar( 'wgDBuser' ) );
|
||||
|
|
@ -175,6 +213,8 @@ class OracleInstaller extends DatabaseInstaller {
|
|||
return $status;
|
||||
}
|
||||
|
||||
$this->setupSchemaVars();
|
||||
|
||||
if ( !$this->db->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
|
||||
$this->db->setFlag( DBO_DDLMODE );
|
||||
$error = $this->db->sourceFile( "$IP/maintenance/oracle/user.sql" );
|
||||
|
|
@ -183,6 +223,7 @@ class OracleInstaller extends DatabaseInstaller {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
|
@ -190,6 +231,8 @@ class OracleInstaller extends DatabaseInstaller {
|
|||
* Overload: after this action field info table has to be rebuilt
|
||||
*/
|
||||
public function createTables() {
|
||||
$this->setupSchemaVars();
|
||||
$this->db->selectDB( $this->getVar( 'wgDBuser' ) );
|
||||
$status = parent::createTables();
|
||||
|
||||
$this->db->query( 'BEGIN fill_wiki_info; END;' );
|
||||
|
|
@ -198,13 +241,21 @@ class OracleInstaller extends DatabaseInstaller {
|
|||
}
|
||||
|
||||
public function getSchemaVars() {
|
||||
/**
|
||||
* The variables $_OracleDefTS, $_OracleTempTS are used by maintenance/oracle/user.sql
|
||||
*/
|
||||
return array(
|
||||
'_OracleDefTS' => $this->getVar( '_OracleDefTS' ),
|
||||
'_OracleTempTS' => $this->getVar( '_OracleTempTS' ),
|
||||
$varNames = array(
|
||||
# These variables are used by maintenance/oracle/user.sql
|
||||
'_OracleDefTS',
|
||||
'_OracleTempTS',
|
||||
'wgDBuser',
|
||||
'wgDBpassword',
|
||||
|
||||
# These are used by tables.sql
|
||||
'wgDBprefix',
|
||||
);
|
||||
$vars = array();
|
||||
foreach ( $varNames as $name ) {
|
||||
$vars[$name] = $this->getVar( $name );
|
||||
}
|
||||
return $vars;
|
||||
}
|
||||
|
||||
public function getLocalSettings() {
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ class PostgresInstaller extends DatabaseInstaller {
|
|||
if ( !$status->isOK() ) {
|
||||
return $status;
|
||||
}
|
||||
$this->setupSchemaVars();
|
||||
$conn = $status->value;
|
||||
|
||||
$dbName = $this->getVar( 'wgDBname' );
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ class SqliteInstaller extends DatabaseInstaller {
|
|||
$this->setVar( 'wgDBserver', '' );
|
||||
$this->setVar( 'wgDBuser', '' );
|
||||
$this->setVar( 'wgDBpassword', '' );
|
||||
$this->setupSchemaVars();
|
||||
return $this->getConnection();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -246,8 +246,16 @@ class SearchOracle extends SearchEngine {
|
|||
'si_title' => $title,
|
||||
'si_text' => $text
|
||||
), 'SearchOracle::update' );
|
||||
$dbw->query("CALL ctx_ddl.sync_index('si_text_idx')");
|
||||
$dbw->query("CALL ctx_ddl.sync_index('si_title_idx')");
|
||||
|
||||
// Sync the index
|
||||
// We need to specify the DB name (i.e. user/schema) here so that
|
||||
// it can work from the installer, where
|
||||
// ALTER SESSION SET CURRENT_SCHEMA = ...
|
||||
// was used.
|
||||
$dbw->query( "CALL ctx_ddl.sync_index(" .
|
||||
$dbw->addQuotes( $dbw->getDBname() . '.si_text_idx' ) . ")" );
|
||||
$dbw->query( "CALL ctx_ddl.sync_index(" .
|
||||
$dbw->addQuotes( $dbw->getDBname() . '.si_title_idx' ) . ")" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -610,8 +610,8 @@ ALTER TABLE &mw_prefix.valid_tag ADD CONSTRAINT &mw_prefix.valid_tag_pk PRIMARY
|
|||
--);
|
||||
--CREATE UNIQUE INDEX &mw_prefix.profiling_u01 ON &mw_prefix.profiling (pf_name, pf_server);
|
||||
|
||||
CREATE INDEX si_title_idx ON &mw_prefix.searchindex(si_title) INDEXTYPE IS ctxsys.context;
|
||||
CREATE INDEX si_text_idx ON &mw_prefix.searchindex(si_text) INDEXTYPE IS ctxsys.context;
|
||||
CREATE INDEX &mw_prefix.si_title_idx ON &mw_prefix.searchindex(si_title) INDEXTYPE IS ctxsys.context;
|
||||
CREATE INDEX &mw_prefix.si_text_idx ON &mw_prefix.searchindex(si_text) INDEXTYPE IS ctxsys.context;
|
||||
|
||||
CREATE TABLE &mw_prefix.l10n_cache (
|
||||
lc_lang varchar2(32) NOT NULL,
|
||||
|
|
|
|||
Loading…
Reference in a new issue