# HG changeset patch # User Sebastien Jodogne # Date 1614789090 -3600 # Node ID 2a0f8031fb93d4302cdd25f2668127c266820f1e # Parent 456ed3fcff8107916eb8b1dc31a2c37a4ae32b54 removed abstraction IDatabaseWrapper::ITransaction::Begin(), must be done by IDatabaseWrapper::StartTransaction() diff -r 456ed3fcff81 -r 2a0f8031fb93 OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp --- a/OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp Wed Mar 03 17:13:41 2021 +0100 +++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp Wed Mar 03 17:31:30 2021 +0100 @@ -67,7 +67,7 @@ { } - virtual void Begin() ORTHANC_OVERRIDE + void Begin() { CheckSuccess(that_.backend_.startTransaction(that_.payload_)); } @@ -891,7 +891,9 @@ IDatabaseWrapper::ITransaction* OrthancPluginDatabase::StartTransaction() { - return new Transaction(*this); + std::unique_ptr transaction(new Transaction(*this)); + transaction->Begin(); + return transaction.release(); } diff -r 456ed3fcff81 -r 2a0f8031fb93 OrthancServer/Sources/Database/IDatabaseWrapper.h --- a/OrthancServer/Sources/Database/IDatabaseWrapper.h Wed Mar 03 17:13:41 2021 +0100 +++ b/OrthancServer/Sources/Database/IDatabaseWrapper.h Wed Mar 03 17:31:30 2021 +0100 @@ -61,8 +61,6 @@ { } - virtual void Begin() = 0; - virtual void Rollback() = 0; virtual void Commit(int64_t fileSizeDelta) = 0; diff -r 456ed3fcff81 -r 2a0f8031fb93 OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Wed Mar 03 17:13:41 2021 +0100 +++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Wed Mar 03 17:31:30 2021 +0100 @@ -60,17 +60,17 @@ { } - virtual const char* GetName() const + virtual const char* GetName() const ORTHANC_OVERRIDE { return "SignalFileDeleted"; } - virtual unsigned int GetCardinality() const + virtual unsigned int GetCardinality() const ORTHANC_OVERRIDE { return 7; } - virtual void Compute(SQLite::FunctionContext& context) + virtual void Compute(SQLite::FunctionContext& context) ORTHANC_OVERRIDE { std::string uncompressedMD5, compressedMD5; @@ -107,17 +107,17 @@ { } - virtual const char* GetName() const + virtual const char* GetName() const ORTHANC_OVERRIDE { return "SignalResourceDeleted"; } - virtual unsigned int GetCardinality() const + virtual unsigned int GetCardinality() const ORTHANC_OVERRIDE { return 2; } - virtual void Compute(SQLite::FunctionContext& context) + virtual void Compute(SQLite::FunctionContext& context) ORTHANC_OVERRIDE { ResourceType type = static_cast(context.GetIntValue(1)); ServerIndexChange change(ChangeType_Deleted, type, context.GetStringValue(0)); @@ -143,17 +143,17 @@ hasRemainingAncestor_ = false; } - virtual const char* GetName() const + virtual const char* GetName() const ORTHANC_OVERRIDE { return "SignalRemainingAncestor"; } - virtual unsigned int GetCardinality() const + virtual unsigned int GetCardinality() const ORTHANC_OVERRIDE { return 2; } - virtual void Compute(SQLite::FunctionContext& context) + virtual void Compute(SQLite::FunctionContext& context) ORTHANC_OVERRIDE { CLOG(TRACE, SQLITE) << "There exists a remaining ancestor with public ID \"" << context.GetStringValue(0) << "\" of type " @@ -617,17 +617,17 @@ #endif } - virtual void Begin() + void Begin() { transaction_->Begin(); } - virtual void Rollback() + virtual void Rollback() ORTHANC_OVERRIDE { transaction_->Rollback(); } - virtual void Commit(int64_t fileSizeDelta /* only used in debug */) + virtual void Commit(int64_t fileSizeDelta /* only used in debug */) ORTHANC_OVERRIDE { transaction_->Commit(); @@ -639,7 +639,9 @@ IDatabaseWrapper::ITransaction* SQLiteDatabaseWrapper::StartTransaction() { - return new Transaction(*this); + std::unique_ptr transaction(new Transaction(*this)); + transaction->Begin(); + return transaction.release(); } @@ -1160,18 +1162,18 @@ std::list values_; public: - virtual std::string GenerateParameter(const std::string& value) + virtual std::string GenerateParameter(const std::string& value) ORTHANC_OVERRIDE { values_.push_back(value); return "?"; } - virtual std::string FormatResourceType(ResourceType level) + virtual std::string FormatResourceType(ResourceType level) ORTHANC_OVERRIDE { return boost::lexical_cast(level); } - virtual std::string FormatWildcardEscape() + virtual std::string FormatWildcardEscape() ORTHANC_OVERRIDE { return "ESCAPE '\\'"; } diff -r 456ed3fcff81 -r 2a0f8031fb93 OrthancServer/Sources/ServerIndex.cpp --- a/OrthancServer/Sources/ServerIndex.cpp Wed Mar 03 17:13:41 2021 +0100 +++ b/OrthancServer/Sources/ServerIndex.cpp Wed Mar 03 17:31:30 2021 +0100 @@ -251,8 +251,6 @@ isCommitted_(false) { transaction_.reset(index_.db_.StartTransaction()); - transaction_->Begin(); - index_.listener_->StartTransaction(); }