Remove dupe implementations of begin/commit from Postgres. Also included checks for...
authorChad Horohoe <demon@users.mediawiki.org>
Fri, 6 Aug 2010 12:54:39 +0000 (12:54 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Fri, 6 Aug 2010 12:54:39 +0000 (12:54 +0000)
includes/db/Database.php
includes/db/DatabasePostgres.php

index 948b9bf..f6756e9 100644 (file)
@@ -1982,8 +1982,10 @@ abstract class DatabaseBase {
         * End a transaction
         */
        function commit( $fname = 'Database::commit' ) {
-               $this->query( 'COMMIT', $fname );
-               $this->mTrxLevel = 0;
+               if( $this->mTrxLevel ) {
+                       $this->query( 'COMMIT', $fname );
+                       $this->mTrxLevel = 0;
+               }
        }
 
        /**
@@ -1991,8 +1993,10 @@ abstract class DatabaseBase {
         * No-op on non-transactional databases.
         */
        function rollback( $fname = 'Database::rollback' ) {
-               $this->query( 'ROLLBACK', $fname, true );
-               $this->mTrxLevel = 0;
+               if( $this->mTrxLevel ) {
+                       $this->query( 'ROLLBACK', $fname, true );
+                       $this->mTrxLevel = 0;
+               }
        }
 
        /**
index af5f30c..34bf99c 100644 (file)
@@ -1282,16 +1282,6 @@ SQL;
                return pg_field_type( $res, $index );
        }
 
-       function begin( $fname = 'DatabasePostgres::begin' ) {
-               $this->query( 'BEGIN', $fname );
-               $this->mTrxLevel = 1;
-       }
-
-       function commit( $fname = 'DatabasePostgres::commit' ) {
-               $this->query( 'COMMIT', $fname );
-               $this->mTrxLevel = 0;
-       }
-
        /* Not even sure why this is used in the main codebase... */
        function limitResultForUpdate( $sql, $num ) {
                return $sql;