From 4aad2397a5a76a3d36d41d29b4896ef5c3d3f218 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 28 Sep 2010 09:36:25 +0200 Subject: [PATCH] [entropy.db] EntropyRepository: make _migrateCountersTable() atomic --- libraries/entropy/db/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/entropy/db/__init__.py b/libraries/entropy/db/__init__.py index 140f38e6f..4d16f72c5 100644 --- a/libraries/entropy/db/__init__.py +++ b/libraries/entropy/db/__init__.py @@ -5200,6 +5200,7 @@ class EntropyRepository(EntropyRepositoryBase): def _migrateCountersTable(self): self._cursor().executescript(""" + BEGIN TRANSACTION; DROP TABLE IF EXISTS counterstemp; CREATE TABLE counterstemp ( counter INTEGER, idpackage INTEGER, branch VARCHAR, @@ -5208,10 +5209,10 @@ class EntropyRepository(EntropyRepositoryBase): ); INSERT INTO counterstemp (counter, idpackage, branch) SELECT counter, idpackage, branch FROM counters; - DROP TABLE counters; + DROP TABLE IF EXISTS counters; ALTER TABLE counterstemp RENAME TO counters; + COMMIT; """) - self.commitChanges() self.__clearLiveCache("_doesTableExist") self.__clearLiveCache("_doesColumnInTableExist")