# HG changeset patch # User František Kučera # Date 1572374768 -3600 # Node ID b295f8985f1381c62a4625631481dff46a5aa6e4 # Parent 44db9e1e7c7f00cab3ec28060eaf85069f3c0e8b run whole transformation in a single transaction diff -r 44db9e1e7c7f -r b295f8985f13 src/SqlHandler.h --- a/src/SqlHandler.h Tue Oct 29 00:23:56 2019 +0100 +++ b/src/SqlHandler.h Tue Oct 29 19:46:08 2019 +0100 @@ -137,6 +137,18 @@ else throw SqlException(L"Unable to prepare SQLite statement."); } + void transactionBegin() { + sqlite3_exec(db, "BEGIN", nullptr, nullptr, nullptr); + } + + void transactionCommit() { + sqlite3_exec(db, "COMMIT", nullptr, nullptr, nullptr); + } + + void transactionRollback() { + sqlite3_exec(db, "ROLLBACK", nullptr, nullptr, nullptr); + } + }; class SqlHandler : public RelationalReaderValueHandler { @@ -248,6 +260,7 @@ } connection.reset(new Connection(file.c_str())); + connection->transactionBegin(); } virtual ~SqlHandler() { @@ -335,6 +348,8 @@ // pass-through some relations: for (const CopyRelations& copy : configuration.copyRelations) copyRelations(copy); + + connection->transactionCommit(); // delete or keep the file: if (configuration.file.size()) {