Skip to content

Commit

Permalink
Merge pull request OSGeo#8473 from rouault/ogr2ogr_gt_0
Browse files Browse the repository at this point in the history
ogr2ogr: fix -gt 0 to disable transactions
  • Loading branch information
rouault authored Sep 26, 2023
2 parents ee8547c + 77b93d3 commit c095015
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/ogr2ogr_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4820,7 +4820,7 @@ SetupTargetLayer::Setup(OGRLayer *poSrcLayer, const char *pszNewLayerName,

if (bOverwriteActuallyDone && !bAddOverwriteLCO &&
EQUAL(m_poDstDS->GetDriver()->GetDescription(), "PostgreSQL") &&
!psOptions->nLayerTransaction && psOptions->nGroupTransactions >= 0 &&
!psOptions->nLayerTransaction && psOptions->nGroupTransactions > 0 &&
CPLTestBool(CPLGetConfigOption("PG_COMMIT_WHEN_OVERWRITING", "YES")))
{
CPLDebug("GDALVectorTranslate",
Expand Down Expand Up @@ -5380,7 +5380,7 @@ int LayerTranslator::Translate(OGRFeature *poFeatureIn, TargetLayerInfo *psInfo,
nFeaturesInTransaction = 0;
}
else if (!psOptions->nLayerTransaction &&
psOptions->nGroupTransactions >= 0 &&
psOptions->nGroupTransactions > 0 &&
++nTotalEventsDone >= psOptions->nGroupTransactions)
{
if (m_poODS->CommitTransaction() == OGRERR_FAILURE ||
Expand Down
5 changes: 0 additions & 5 deletions autotest/utilities/test_ogr2ogr_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1521,11 +1521,6 @@ def test_ogr2ogr_lib_transaction_size(transaction_size):
)

try:
# A transaction size of 0 is invalid
if transaction_size == 0:
assert ds is None
return

assert ds is not None
lyr = ds.GetLayer(0)
assert lyr.GetFeatureCount() == 10, "wrong feature count"
Expand Down

0 comments on commit c095015

Please sign in to comment.