* @ingroup Database
*/
-/**
- * @ingroup Database
- */
-class ORABlob {
- var $mData;
-
- function __construct( $data ) {
- $this->mData = $data;
- }
-
- function getData() {
- return $this->mData;
- }
-}
-
/**
* The oci8 extension is fairly weak and doesn't support oci_num_rows, among
* other things. We use a wrapper class to handle that and other
}
if ( $val === null ) {
- if ( $col_info != false && $col_info->nullable() == 0 && $col_info->defaultValue() != null ) {
+ if ( $col_info != false && $col_info->isNullable() == 0 && $col_info->defaultValue() != null ) {
$bind .= 'DEFAULT';
} else {
$bind .= 'NULL';
return $this->doQuery( 'BEGIN DUPLICATE_TABLE(\'' . $tabName . '\', \'' . $oldPrefix . '\', \'' . strtoupper( $wgDBprefix ) . '\', ' . $temporary . '); END;' );
}
+ function listTables( $prefix = null, $fname = 'DatabaseOracle::listTables' ) {
+ $listWhere = '';
+ if (!empty($prefix)) {
+ $listWhere = ' AND table_name LIKE \''.strtoupper($prefix).'%\'';
+ }
+
+ $result = $this->doQuery( "SELECT table_name FROM user_tables WHERE table_name NOT LIKE '%!_IDX$_' ESCAPE '!' $listWhere" );
+
+ // dirty code ... i know
+ $endArray = array();
+ $endArray[] = $prefix.'MWUSER';
+ $endArray[] = $prefix.'PAGE';
+ $endArray[] = $prefix.'IMAGE';
+ $fixedOrderTabs = $endArray;
+ while (($row = $result->fetchRow()) !== false) {
+ if (!in_array($row['table_name'], $fixedOrderTabs))
+ $endArray[] = $row['table_name'];
+ }
+
+ return $endArray;
+ }
+
+ public function dropTable( $tableName, $fName = 'DatabaseOracle::dropTable' ) {
+ $tableName = $this->tableName($tableName);
+ if( !$this->tableExists( $tableName ) ) {
+ return false;
+ }
+
+ return $this->doQuery( "DROP TABLE $tableName CASCADE CONSTRAINTS PURGE" );
+ }
+
function timestamp( $ts = 0 ) {
return wfTimestamp( TS_ORACLE, $ts );
}
}
} else {
foreach ( $replacements as $mwVar => $scVar ) {
- $cmd = str_replace( '&' . $scVar . '.', '{$' . $mwVar . '}', $cmd );
+ $cmd = str_replace( '&' . $scVar . '.', '`{$' . $mwVar . '}`', $cmd );
}
$cmd = $this->replaceVars( $cmd );
return "'" . $this->strencode( $s ) . "'";
}
+ public function addIdentifierQuotes( $s ) {
+ if ( !$this->mFlags & DBO_DDLMODE ) {
+ $s = '"' . str_replace( '"', '""', $s ) . '"';
+ }
+ return $s;
+ }
+
function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) {
global $wgContLang;
- $conds2 = array();
- $conds = ( $conds != null && !is_array( $conds ) ) ? array( $conds ) : $conds;
- foreach ( $conds as $col => $val ) {
- $col_info = $this->fieldInfoMulti( $table, $col );
- $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
- if ( $col_type == 'CLOB' ) {
- $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding( $val );
- } elseif ( $col_type == 'VARCHAR2' && !mb_check_encoding( $val ) ) {
- $conds2[$col] = $wgContLang->checkTitleEncoding( $val );
- } else {
- $conds2[$col] = $val;
+ if ($conds != null) {
+ $conds2 = array();
+ $conds = ( !is_array( $conds ) ) ? array( $conds ) : $conds;
+ foreach ( $conds as $col => $val ) {
+ $col_info = $this->fieldInfoMulti( $table, $col );
+ $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
+ if ( $col_type == 'CLOB' ) {
+ $conds2['TO_CHAR(' . $col . ')'] = $wgContLang->checkTitleEncoding( $val );
+ } elseif ( $col_type == 'VARCHAR2' && !mb_check_encoding( $val ) ) {
+ $conds2[$col] = $wgContLang->checkTitleEncoding( $val );
+ } else {
+ $conds2[$col] = $val;
+ }
}
+
+ return parent::selectRow( $table, $vars, $conds2, $fname, $options, $join_conds );
+ } else {
+ return parent::selectRow( $table, $vars, $conds, $fname, $options, $join_conds );
}
-
- return parent::selectRow( $table, $vars, $conds2, $fname, $options, $join_conds );
}
/**
public function delete( $table, $conds, $fname = 'DatabaseOracle::delete' ) {
global $wgContLang;
- if ( $wgContLang != null && $conds != '*' ) {
+ if ( $wgContLang != null && $conds != null && $conds != '*' ) {
$conds2 = array();
- $conds = ( $conds != null && !is_array( $conds ) ) ? array( $conds ) : $conds;
+ $conds = ( !is_array( $conds ) ) ? array( $conds ) : $conds;
foreach ( $conds as $col => $val ) {
$col_info = $this->fieldInfoMulti( $table, $col );
$col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
protected $internalDefaults = array(
'_OracleDefTS' => 'USERS',
- '_OracleTempTS' => 'TEMP',
- '_OracleUseSysdba' => true
+ '_OracleTempTS' => 'TEMP'
);
+
+ protected $useSysDBA = false;
public $minimumVersion = '9.0.1'; // 9iR1
}
// Try to connect
+ $this->useSysDBA = true;
$status = $this->getConnection();
if ( !$status->isOK() ) {
return $status;
public function getConnection() {
$status = Status::newGood();
try {
- if ( $this->getVar( '_OracleUseSysdba' ) ) {
+ if ( $this->useSysDBA ) {
$this->db = new DatabaseOracle(
$this->getVar( 'wgDBserver' ),
$this->getVar( '_InstallUser' ),
$this->getVar( '_InstallPassword' ),
$this->getVar( 'wgDBname' ),
- DBO_SYSDBA,
+ DBO_SYSDBA | DBO_DDLMODE,
$this->getVar( 'wgDBprefix' )
);
} else {
public function preInstall() {
# Add our user callback to installSteps, right before the tables are created.
$callback = array(
- array(
- 'name' => 'user',
- 'callback' => array( $this, 'setupUser' ),
- )
+ 'name' => 'user',
+ 'callback' => array( $this, 'setupUser' )
);
$this->parent->addInstallStep( $callback, 'database' );
}
public function setupDatabase() {
- $this->parent->setVar( '_OracleUseSysdba', false );
+ $this->useSysDBA = false;
$status = Status::newGood();
return $status;
}
if ( !$this->getVar( '_CreateDBAccount' ) ) {
return Status::newGood();
}
+
+ $this->useSysDBA = true;
$status = $this->getConnection();
if ( !$status->isOK() ) {
return $status;
*/
$GLOBALS['_OracleDefTS'] = $this->getVar( '_OracleDefTS' );
$GLOBALS['_OracleTempTS'] = $this->getVar( '_OracleTempTS' );
+ $this->db->setFlag( DBO_DDLMODE );
$error = $this->db->sourceFile( "$IP/maintenance/oracle/user.sql" );
if ( $error !== true || !$this->db->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
$status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $error );