From 1e3b85f27f46467c3997273baa69e872b195c8a2 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 10 May 2006 14:23:38 +0000 Subject: [PATCH] * src/GrampsDb/_DbUtils.py (db_copy): Use batch transaction. * src/GrampsDb/_GrampsBSDDB.py (transaction_begin): Proper indentation. svn: r6606 --- ChangeLog | 4 ++++ src/GrampsDb/_DbUtils.py | 6 ++++++ src/GrampsDb/_GrampsBSDDB.py | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4930dd827..852a650b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-05-10 Alex Roitman + * src/GrampsDb/_DbUtils.py (db_copy): Use batch transaction. + * src/GrampsDb/_GrampsBSDDB.py (transaction_begin): Proper indentation. + 2006-05-09 Don Allingham * src/DataViews/_PersonView.py: search bar implementation * src/PeopleModel.py: search bar implementation diff --git a/src/GrampsDb/_DbUtils.py b/src/GrampsDb/_DbUtils.py index eabeddb5b..f94505402 100644 --- a/src/GrampsDb/_DbUtils.py +++ b/src/GrampsDb/_DbUtils.py @@ -193,6 +193,9 @@ def db_copy(from_db,to_db,callback): oldval = 0 count = 0 + # Start batch transaction to use async TXN and other tricks + trans = to_db.transaction_begin("",batch=True) + for table_name in primary_tables.keys(): cursor_func = primary_tables[table_name]['cursor_func'] table = primary_tables[table_name]['table'] @@ -207,6 +210,9 @@ def db_copy(from_db,to_db,callback): update(callback,count,oldval,total) cursor.close() + # Commit batch transaction: does nothing, except undoing the tricks + to_db.transaction_commit(trans,"") + # The metadata is always transactionless, # and the table is small, so using key iteration is OK here. for handle in from_db.metadata.keys(): diff --git a/src/GrampsDb/_GrampsBSDDB.py b/src/GrampsDb/_GrampsBSDDB.py index 5375e1cc9..021b775fc 100644 --- a/src/GrampsDb/_GrampsBSDDB.py +++ b/src/GrampsDb/_GrampsBSDDB.py @@ -1076,7 +1076,7 @@ class GrampsBSDDB(GrampsDbBase): if transaction.batch: if self.UseTXN: self.env.txn_checkpoint() - self.env.set_flags(db.DB_TXN_NOSYNC,1) # async txn + self.env.set_flags(db.DB_TXN_NOSYNC,1) # async txn if self.secondary_connected and not transaction.no_magic: # Disconnect unneeded secondary indices