From: Jure Kajzer Date: Fri, 22 Apr 2011 11:31:18 +0000 (+0000) Subject: * begin, commit, rollback functions updated X-Git-Tag: 1.31.0-rc.0~30638 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=398a7891f884565c43eb8f87b4d1c0ee5407c40e;p=lhc%2Fweb%2Fwiklou.git * begin, commit, rollback functions updated * using ->execFlags instead of hardcoded OCI_DEFAULT * added dummy page (id=0) to satisfy FK checks --- diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 25c1586b09..794710b046 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -275,6 +275,9 @@ class DatabaseOracle extends DatabaseBase { function close() { $this->mOpened = false; if ( $this->mConn ) { + if ( $this->mTrxLevel ) { + $this->commit(); + } return oci_close( $this->mConn ); } else { return true; @@ -559,7 +562,7 @@ class DatabaseOracle extends DatabaseBase { wfSuppressWarnings(); - if ( oci_execute( $stmt, OCI_DEFAULT ) === false ) { + if ( oci_execute( $stmt, $this->execFlags() ) === false ) { $e = oci_error( $stmt ); if ( !$this->ignore_DUP_VAL_ON_INDEX || $e['code'] != '1' ) { $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ ); @@ -921,7 +924,7 @@ class DatabaseOracle extends DatabaseBase { } $fieldInfoStmt = oci_parse( $this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name '.$tableWhere.' and column_name = \''.$field.'\'' ); - if ( oci_execute( $fieldInfoStmt, OCI_DEFAULT ) === false ) { + if ( oci_execute( $fieldInfoStmt, $this->execFlags() ) === false ) { $e = oci_error( $fieldInfoStmt ); $this->reportQueryError( $e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__ ); return false; @@ -958,13 +961,22 @@ class DatabaseOracle extends DatabaseBase { return $this->fieldInfoMulti ($table, $field); } - function begin( $fname = '' ) { + function begin( $fname = 'DatabaseOracle::begin' ) { $this->mTrxLevel = 1; } - function commit( $fname = '' ) { - oci_commit( $this->mConn ); - $this->mTrxLevel = 0; + function commit( $fname = 'DatabaseOracle::commit' ) { + if ( $this->mTrxLevel ) { + oci_commit( $this->mConn ); + $this->mTrxLevel = 0; + } + } + + function rollback( $fname = 'DatabaseOracle::rollback' ) { + if ( $this->mTrxLevel ) { + oci_rollback( $this->mConn ); + $this->mTrxLevel = 0; + } } /* Not even sure why this is used in the main codebase... */ @@ -1085,7 +1097,7 @@ class DatabaseOracle extends DatabaseBase { } public function removeIdentifierQuotes( $s ) { - return strpos($s, '/*Q*/') === FALSE ? $s : substr($s, 5); + return strpos($s, '/*Q*/') === FALSE ? $s : substr($s, 5); ; } public function isQuotedIdentifier( $s ) { @@ -1255,7 +1267,7 @@ class DatabaseOracle extends DatabaseBase { wfSuppressWarnings(); - if ( oci_execute( $stmt, OCI_DEFAULT ) === false ) { + if ( oci_execute( $stmt, $this->execFlags() ) === false ) { $e = oci_error( $stmt ); if ( !$this->ignore_DUP_VAL_ON_INDEX || $e['code'] != '1' ) { $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ ); diff --git a/maintenance/oracle/tables.sql b/maintenance/oracle/tables.sql index 1f9db86615..b8ecc2b96a 100644 --- a/maintenance/oracle/tables.sql +++ b/maintenance/oracle/tables.sql @@ -72,6 +72,10 @@ CREATE UNIQUE INDEX &mw_prefix.page_u01 ON &mw_prefix.page (page_namespace,page_ CREATE INDEX &mw_prefix.page_i01 ON &mw_prefix.page (page_random); CREATE INDEX &mw_prefix.page_i02 ON &mw_prefix.page (page_len); +-- Create a dummy page to satisfy fk contraints especially with revisions +INSERT INTO &mw_prefix.page + VALUES (0, 0, ' ', NULL, 0, 0, 0, 0, current_timestamp, 0, 0); + /*$mw$*/ CREATE TRIGGER &mw_prefix.page_set_random BEFORE INSERT ON &mw_prefix.page FOR EACH ROW WHEN (new.page_random IS NULL)