Opened 17 years ago

Last modified 17 years ago

#1514 closed defect (fixed)

Query results not cleaned in Soft Transactions of PG

Reported by: Mateusz Łoskot Owned by: Mateusz Łoskot
Priority: high Milestone:
Component: OGR_SF Version: 1.4.0
Severity: major Keywords:
Cc:

Description (last modified by Mateusz Łoskot)

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 (4)

comment:1 by warmerdam, 17 years ago

this is unintentional.  Please correct. 

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

comment:2 by Mateusz Łoskot, 17 years ago

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.

comment:4 by Mateusz Łoskot, 17 years ago

Description: modified (diff)

comment:5 by Mateusz Łoskot, 17 years ago

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

Note: See TracTickets for help on using tickets.