[gdal-dev] transactions and ExecuteSQL

Even Rouault even.rouault at mines-paris.org
Fri Aug 19 11:23:06 EDT 2011

Selon Martin Landa <landa.martin at gmail.com>:

> Hi,
> how to deal with transactions when calling ExecuteSQL()? Example for
> PostGIS layer
> """
>     poDS = OGRSFDriverRegistrar::Open("PG:dbname=pgis_nc", FALSE);
>     poLayer = poDS->GetLayerByName("b_1");
>     poLayer->StartTransaction();
>     poDS->ExecuteSQL("update b_1 set objectid = 5 where cat = 4", NULL,
> NULL);
>     poLayer->CommitTransaction();
> """
> Calling StartTransaction() and CommitTransaction() has no effect since
> ExecuteSQL() calls FlushSoftTransaction(). How to deal with that?

The transaction mechanism is currently only designed to operate when doing
operation on a same layer, so I guess it's the reason that COMMIT is forced when
you call ExecuteSQL() that can have potentially effects on things unrelated.
With the current implementation, I don't see any way of having ExecuteSQL()
doing things in an already existing transaction. You will have to modify the
code for that. AFAIR, there's a patch in Trac that tried to bring per-datasource
transactions. But that would need extending the OGR API and analysing the
impacts of how interleaved operations on different layers would work.

> Thanks in advance, Martin
> --
> Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

More information about the gdal-dev mailing list