Clear previously left-over PQresult before calling pg_get_result()
authoryoonghm <yoonghm@gmail.com>
Sun, 27 Sep 2015 05:56:29 +0000 (13:56 +0800)
committerKunal Mehta <legoktm@gmail.com>
Sat, 10 Oct 2015 16:03:59 +0000 (12:03 -0400)
Bug: T52091
Change-Id: Iaa1a479b5eefcae0fc8f82b1d20e9575d609c0e9

includes/db/DatabasePostgres.php

index c9d7b35..64ae1c6 100644 (file)
@@ -395,6 +395,9 @@ class DatabasePostgres extends Database {
                if ( function_exists( 'mb_convert_encoding' ) ) {
                        $sql = mb_convert_encoding( $sql, 'UTF-8' );
                }
+               // Clear previously left over PQresult
+               while ( $res = pg_get_result( $this->mConn ) )
+                       pg_free_result( $res );
                if ( pg_send_query( $this->mConn, $sql ) === false ) {
                        throw new DBUnexpectedError( $this, "Unable to post new query to PostgreSQL\n" );
                }