Ticket #1514 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

Query results not cleaned in Soft Transactions of PG

Reported by: mloskot Owned by: mloskot
Priority: high Milestone:
Component: OGR_SF Version: 1.4.0
Severity: major Keywords:
Cc:

Description (last modified by mloskot) (diff)

In functions operating on Soft Transactions, query results are not properly released when error occur. Is it intentional?

For example, in OGRPGDataSource::SoftRollback?()

hResult = PQexec(hPGConn, "ROLLBACK");

if( !hResult || PQresultStatus(hResult) != PGRES_COMMAND_OK )
   return OGRERR_FAILURE;

PQclear( hResult );

The PQclear() call is missing before return OGRERR_FAILURE.

Change History

Changed 6 years ago by warmerdam

this is unintentional.  Please correct. 

Take care of course to not try and release a NULL hResult.

Changed 6 years ago by mloskot

The bug has been fixed.

Here is detailed changeset:
http://trac.osgeo.org/gdal/changeset/10931

Along refactoring, new file has been added - ogrpgutility.h - with inline free
function OGRPGClearResult() which is a simple and safe wrapper on PQclear()

http://trac.osgeo.org/gdal/browser/trunk/gdal/ogr/ogrsf_frmts/pg/ogrpgutility.h

Everything builds locally and on Buildbot.
All autotests pass.
Manually executed tests using ogrinfo pass, without any complains from Valgrind.

Changed 6 years ago by mloskot

  • description modified (diff)

Changed 6 years ago by mloskot

I ported the fix to the stable branch 1.4. (r11225).

Note: See TracTickets for help on using tickets.