From: Greg Sabino Mullane Date: Tue, 9 Feb 2016 16:38:21 +0000 (-0500) Subject: Use pg_result_error, not pg_last_error, as the latter gives false negatives. X-Git-Tag: 1.31.0-rc.0~7345^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=290829ae0dc74488f8c97ba2c66cc2ee2d9380b0;p=lhc%2Fweb%2Fwiklou.git Use pg_result_error, not pg_last_error, as the latter gives false negatives. Specifically in the savepoint part of the code, where a failed query inside the savepoint gives a non-false reply to pg_last_error by the time we call it, which then leads to us doing 'RELEASE' instead of 'ROLLBACK TO', and causes all sorts of mayhem. The whole system needs a little cleanup, but this is an important bandaid. Change-Id: I0223a3599816db5650f45863400e6194468d4361 --- diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index e84f264d1e..c8dcc88fbe 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -840,7 +840,7 @@ __INDEXATTR__; $tempres = (bool)$this->query( $tempsql, $fname, $savepoint ); if ( $savepoint ) { - $bar = pg_last_error(); + $bar = pg_result_error( $this->mLastResult ); if ( $bar != false ) { $savepoint->rollback(); } else { @@ -865,7 +865,7 @@ __INDEXATTR__; $sql .= '(' . $this->makeList( $args ) . ')'; $res = (bool)$this->query( $sql, $fname, $savepoint ); if ( $savepoint ) { - $bar = pg_last_error(); + $bar = pg_result_error( $this->mLastResult ); if ( $bar != false ) { $savepoint->rollback(); } else { @@ -948,7 +948,7 @@ __INDEXATTR__; $res = (bool)$this->query( $sql, $fname, $savepoint ); if ( $savepoint ) { - $bar = pg_last_error(); + $bar = pg_result_error( $this->mLastResult ); if ( $bar != false ) { $savepoint->rollback(); } else {