* begin, commit, rollback functions updated
authorJure Kajzer <freakolowsky@users.mediawiki.org>
Fri, 22 Apr 2011 11:31:18 +0000 (11:31 +0000)
committerJure Kajzer <freakolowsky@users.mediawiki.org>
Fri, 22 Apr 2011 11:31:18 +0000 (11:31 +0000)
* using ->execFlags instead of hardcoded OCI_DEFAULT
* added dummy page (id=0) to satisfy FK checks

includes/db/DatabaseOracle.php
maintenance/oracle/tables.sql

index 25c1586..794710b 100644 (file)
@@ -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__ );
index 1f9db86..b8ecc2b 100644 (file)
@@ -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)