Mercurial > hg > orthanc-databases
diff Framework/Common/DatabaseManager.cpp @ 12:41543239072d
transactions for storage area
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Jul 2018 18:34:56 +0200 |
parents | 7cea966b6829 |
children | c7c54993a92e |
line wrap: on
line diff
--- a/Framework/Common/DatabaseManager.cpp Mon Jul 09 11:45:52 2018 +0200 +++ b/Framework/Common/DatabaseManager.cpp Mon Jul 09 18:34:56 2018 +0200 @@ -286,16 +286,9 @@ } - DatabaseManager::CachedStatement::CachedStatement(const StatementLocation& location, - DatabaseManager& manager, - const char* sql) : - lock_(manager.mutex_), - manager_(manager), - location_(location), - database_(manager.GetDatabase()), - transaction_(manager.GetTransaction()) + void DatabaseManager::CachedStatement::Setup(const char* sql) { - statement_ = manager_.LookupCachedStatement(location); + statement_ = manager_.LookupCachedStatement(location_); if (statement_ == NULL) { @@ -304,10 +297,34 @@ else { LOG(TRACE) << "Reusing cached statement from " - << location.GetFile() << ":" << location.GetLine(); + << location_.GetFile() << ":" << location_.GetLine(); } } + + DatabaseManager::CachedStatement::CachedStatement(const StatementLocation& location, + DatabaseManager& manager, + const char* sql) : + lock_(manager.mutex_), + manager_(manager), + location_(location), + transaction_(manager.GetTransaction()) + { + Setup(sql); + } + + + DatabaseManager::CachedStatement::CachedStatement(const StatementLocation& location, + Transaction& transaction, + const char* sql) : + lock_(manager_.mutex_), + manager_(transaction.GetManager()), + location_(location), + transaction_(manager_.GetTransaction()) + { + Setup(sql); + } + void DatabaseManager::CachedStatement::SetReadOnly(bool readOnly) {