Mercurial > hg > orthanc
changeset 6134:48a49be02483 attach-custom-data
nested sqlite read-only transactions
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 26 May 2025 10:16:52 +0200 |
parents | ffed14a83433 |
children | c0614c7fd73d |
files | OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp |
diffstat | 1 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Wed May 21 23:46:37 2025 +0200 +++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Mon May 26 10:16:52 2025 +0200 @@ -2469,25 +2469,33 @@ { private: SQLiteDatabaseWrapper& that_; + bool isNested_; // see explanation on the ReadWriteTransaction public: ReadOnlyTransaction(SQLiteDatabaseWrapper& that, IDatabaseListener& listener) : TransactionBase(that.mutex_, that.db_, listener, *that.signalRemainingAncestor_), - that_(that) + that_(that), + isNested_(false) { if (that_.activeTransaction_ != NULL) { - throw OrthancException(ErrorCode_InternalError); + isNested_ = true; + // throw OrthancException(ErrorCode_InternalError); } - - that_.activeTransaction_ = this; + else + { + that_.activeTransaction_ = this; + } } virtual ~ReadOnlyTransaction() { - assert(that_.activeTransaction_ != NULL); - that_.activeTransaction_ = NULL; + if (!isNested_) + { + assert(that_.activeTransaction_ != NULL); + that_.activeTransaction_ = NULL; + } } virtual void Rollback() ORTHANC_OVERRIDE