From 72ecbfc12794c74eb61fe93b147f42d4bf8c2910 Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 29 May 2014 23:42:41 -0700 Subject: [PATCH] PostgreSQL: Only rollback when in a transaction SQL errors would issue a rollback, even when it was not actually in a transactions. Doing so would cause another error to be reported. This could obscure the original error, particularly during unit tests. Fix this by not rolling back when not in a transaction. Bug: 58095 Change-Id: Ib5220e37dd6c364feee6b7f8e7ecbdae2a2e0ba1 --- includes/db/DatabasePostgres.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 1cbd1e22c5..3d7267aba4 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -521,7 +521,6 @@ class DatabasePostgres extends DatabaseBase { } function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) { - /* Transaction stays in the ERROR state until rolledback */ if ( $tempIgnore ) { /* Check for constraint violation */ if ( $errno === '23505' ) { @@ -530,8 +529,10 @@ class DatabasePostgres extends DatabaseBase { return; } } - /* Don't ignore serious errors */ - $this->rollback( __METHOD__ ); + /* Transaction stays in the ERROR state until rolledback */ + if ( $this->mTrxLevel ) { + $this->rollback( __METHOD__ ); + }; parent::reportQueryError( $error, $errno, $sql, $fname, false ); } -- 2.20.1