# removed putenv calls because they interfere with the system globaly
$this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' );
$this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' );
+ $this->doQuery( 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS=\'.,\'' );
return $this->mConn;
}
}
function execFlags() {
- return $this->mTrxLevel ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS;
+ return $this->mTrxLevel ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS;
}
function doQuery( $sql ) {
}
$val = ( $wgContLang != null ) ? $wgContLang->checkTitleEncoding( $val ) : $val;
- if ( oci_bind_by_name( $stmt, ":$col", $val ) === false ) {
+ if ( oci_bind_by_name( $stmt, ":$col", $val, -1, SQLT_CHR ) === false ) {
$e = oci_error( $stmt );
$this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
return false;
*/
private function getSequenceData( $table ) {
if ( $this->sequenceData == null ) {
- $result = $this->doQuery( 'SELECT lower(us.sequence_name), lower(utc.table_name), lower(utc.column_name) from user_sequences us, user_tab_columns utc where us.sequence_name = utc.table_name||\'_\'||utc.column_name||\'_SEQ\'' );
+ $result = $this->doQuery( "SELECT lower(asq.sequence_name),
+ lower(atc.table_name),
+ lower(atc.column_name)
+ FROM all_sequences asq, all_tab_columns atc
+ WHERE decode(atc.table_name, '{$this->mTablePrefix}MWUSER', '{$this->mTablePrefix}USER', atc.table_name) || '_' ||
+ atc.column_name || '_SEQ' = '{$this->mTablePrefix}' || asq.sequence_name
+ AND asq.sequence_owner = '{$this->mDBname}'
+ AND atc.owner = '{$this->mDBname}'" );
while ( ( $row = $result->fetchRow() ) !== false ) {
$this->sequenceData[$this->tableName( $row[1] )] = array(
);
}
}
-
+ $table = strtolower( $this->removeIdentifierQuotes( $this->tableName( $table ) ) );
return ( isset( $this->sequenceData[$table] ) ) ? $this->sequenceData[$table] : false;
}
}
function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseOracle::duplicateTableStructure' ) {
- global $wgDBprefix;
- $this->setFlag( DBO_DDLMODE );
-
$temporary = $temporary ? 'TRUE' : 'FALSE';
$newName = strtoupper( $newName );
$oldName = strtoupper( $oldName );
- $tabName = substr( $newName, strlen( $wgDBprefix ) );
+ $tabName = substr( $newName, strlen( $this->mTablePrefix ) );
$oldPrefix = substr( $oldName, 0, strlen( $oldName ) - strlen( $tabName ) );
- $newPrefix = strtoupper( $wgDBprefix );
+ $newPrefix = strtoupper( $this->mTablePrefix );
- $this->clearFlag( DBO_DDLMODE );
return $this->doQuery( "BEGIN DUPLICATE_TABLE( '$tabName', '$oldPrefix', '$newPrefix', $temporary ); END;" );
}
} else {
$count = 0;
}
- return $count != 0;
+ return $count;
}
/**
function begin( $fname = 'DatabaseOracle::begin' ) {
$this->mTrxLevel = 1;
+ $this->doQuery( 'SET CONSTRAINTS ALL DEFERRED' );
}
function commit( $fname = 'DatabaseOracle::commit' ) {
if ( $this->mTrxLevel ) {
- oci_commit( $this->mConn );
+ $ret = oci_commit( $this->mConn );
+ if ( !$ret ) {
+ throw new DBUnexpectedError( $this, $this->lastError() );
+ }
$this->mTrxLevel = 0;
+ $this->doQuery( 'SET CONSTRAINTS ALL IMMEDIATE' );
}
}
if ( $this->mTrxLevel ) {
oci_rollback( $this->mConn );
$this->mTrxLevel = 0;
+ $this->doQuery( 'SET CONSTRAINTS ALL IMMEDIATE' );
}
}
e_table_not_exist EXCEPTION;
PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942);
l_temp_ei_sql VARCHAR2(2000);
+ l_temporary BOOLEAN := p_temporary;
BEGIN
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname ||
WHEN e_table_not_exist THEN
NULL;
END;
- IF (p_temporary) THEN
+ IF (p_tabname = 'SEARCHINDEX') THEN
+ l_temporary := FALSE;
+ END IF;
+ IF (l_temporary) THEN
EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix ||
p_tabname || ' AS SELECT * FROM ' || p_oldprefix ||
p_tabname || ' WHERE ROWNUM = 0';
EXECUTE IMMEDIATE l_temp_ei_sql;
END IF;
END LOOP;
- IF (NOT p_temporary) THEN
+ IF (NOT l_temporary) THEN
FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT',
constraint_name),
32767,
EXECUTE IMMEDIATE l_temp_ei_sql;
END IF;
END LOOP;
+ FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
+ index_name),
+ 32767,
+ 1),
+ USER || '"."' || p_oldprefix,
+ USER || '"."' || p_newprefix),
+ '"' || index_name || '"',
+ '"' || p_newprefix || index_name || '"') DDLVC2,
+ index_name,
+ index_type
+ FROM user_indexes ui
+ WHERE table_name = p_oldprefix || p_tabname
+ AND index_type = 'DOMAIN'
+ AND NOT EXISTS
+ (SELECT NULL
+ FROM user_constraints
+ WHERE table_name = ui.table_name
+ AND constraint_name = ui.index_name)) LOOP
+ l_temp_ei_sql := rc.ddlvc2;
+ IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
+ EXECUTE IMMEDIATE l_temp_ei_sql;
+ END IF;
+ END LOOP;
FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER',
trigger_name),
32767,
e_table_not_exist EXCEPTION;
PRAGMA EXCEPTION_INIT(e_table_not_exist, -00942);
l_temp_ei_sql VARCHAR2(2000);
+ l_temporary BOOLEAN := p_temporary;
BEGIN
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE ' || p_newprefix || p_tabname ||
WHEN e_table_not_exist THEN
NULL;
END;
- IF (p_temporary) THEN
+ IF (p_tabname = 'SEARCHINDEX') THEN
+ l_temporary := FALSE;
+ END IF;
+ IF (l_temporary) THEN
EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE ' || p_newprefix ||
p_tabname || ' AS SELECT * FROM ' || p_oldprefix ||
p_tabname || ' WHERE ROWNUM = 0';
EXECUTE IMMEDIATE l_temp_ei_sql;
END IF;
END LOOP;
- IF (NOT p_temporary) THEN
+ IF (NOT l_temporary) THEN
FOR rc IN (SELECT REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('REF_CONSTRAINT',
constraint_name),
32767,
EXECUTE IMMEDIATE l_temp_ei_sql;
END IF;
END LOOP;
+ FOR rc IN (SELECT REPLACE(REPLACE(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('INDEX',
+ index_name),
+ 32767,
+ 1),
+ USER || '"."' || p_oldprefix,
+ USER || '"."' || p_newprefix),
+ '"' || index_name || '"',
+ '"' || p_newprefix || index_name || '"') DDLVC2,
+ index_name,
+ index_type
+ FROM user_indexes ui
+ WHERE table_name = p_oldprefix || p_tabname
+ AND index_type = 'DOMAIN'
+ AND NOT EXISTS
+ (SELECT NULL
+ FROM user_constraints
+ WHERE table_name = ui.table_name
+ AND constraint_name = ui.index_name)) LOOP
+ l_temp_ei_sql := rc.ddlvc2;
+ IF nvl(length(l_temp_ei_sql), 0) > 0 THEN
+ EXECUTE IMMEDIATE l_temp_ei_sql;
+ END IF;
+ END LOOP;
FOR rc IN (SELECT REPLACE(REPLACE(UPPER(DBMS_LOB.SUBSTR(DBMS_METADATA.get_ddl('TRIGGER',
trigger_name),
32767,
END IF;
END LOOP;
END;
+
/*$mw$*/
/*$mw$*/