Skip to content

Instantly share code, notes, and snippets.

@jef-n
Created January 23, 2016 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jef-n/2f9c4fa778d165cdbda0 to your computer and use it in GitHub Desktop.
Save jef-n/2f9c4fa778d165cdbda0 to your computer and use it in GitHub Desktop.
restart transaction when CreateFeature fails
diff -ur ../orig/gdal-2.0.2/apps/ogr2ogr.cpp ./apps/ogr2ogr.cpp
--- ../orig/gdal-2.0.2/apps/ogr2ogr.cpp 2016-01-22 11:51:09.000000000 +0100
+++ ./apps/ogr2ogr.cpp 2016-01-23 00:43:21.392717800 +0100
@@ -4049,6 +4049,17 @@
{
CPLDebug( "OGR2OGR", "Unable to write feature " CPL_FRMT_GIB " into layer %s.\n",
poFeature->GetFID(), poSrcLayer->GetName() );
+
+ if( bLayerTransaction )
+ {
+ poDstLayer->RollbackTransaction();
+ poDstLayer->StartTransaction();
+ }
+ else
+ {
+ poODS->RollbackTransaction();
+ poODS->StartTransaction(bForceTransaction);
+ }
}
end_loop:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment