On lundi 10 juin 2019 10:19:26 CEST jkellio2 wrote:
> Just in case anyone was curious. The issue here was in the way I was reading
> the result set layer the first time. I only read 1 feature (as that was all
> I was interested in). Evidently that leaves the result set in a busy state.
> I needed to either read the entire layer, i.e.
> 
>       OSGeo.OGR.Feature fea = layer.GetNextFeature();
>       while ( fea != null )
>       {
>         s = fea.GetFieldAsString( "name" );
>         layer.GetNextFeature();
>       }
> 
> Or I needed to reset the layer after reading, i.e.
> 
>       OSGeo.OGR.Feature fea = layer.GetNextFeature();
>       if ( fea != null )
>       {
>         s = fea.GetFieldAsString( "name" );
>       }
>       layer.ResetReading();
> 
> Once I did this I was able to write to the database the second time.

Ah, I missed that. Actually layer.ResetReading() is probably not enough and 
leaks memory.

Layers acquired with layer = ogrDataSource.ExecuteSQL() must be explicitly 
deallocated with
ogrDataSource.ReleaseResultSet(layer)

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to