# HG changeset patch # User Sebastien Jodogne # Date 1626075601 -7200 # Node ID 87f0e29a1dc1392aa3508d8b42081f001770ab46 # Parent dd4b0edd16611910cb284e39faad4bfe2624652e added Dictionary::Clear() diff -r dd4b0edd1661 -r 87f0e29a1dc1 Framework/Common/DatabaseManager.cpp --- a/Framework/Common/DatabaseManager.cpp Fri Jul 09 17:23:24 2021 +0200 +++ b/Framework/Common/DatabaseManager.cpp Mon Jul 12 09:40:01 2021 +0200 @@ -356,20 +356,14 @@ void DatabaseManager::StatementBase::SetResult(IResult* result) { - std::unique_ptr protection(result); - - if (result_.get() != NULL) - { - LOG(ERROR) << "Cannot execute twice a statement"; - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); - } - if (result == NULL) { throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); } - - result_.reset(protection.release()); + else + { + result_.reset(result); + } } diff -r dd4b0edd1661 -r 87f0e29a1dc1 Framework/Common/Dictionary.cpp --- a/Framework/Common/Dictionary.cpp Fri Jul 09 17:23:24 2021 +0200 +++ b/Framework/Common/Dictionary.cpp Mon Jul 12 09:40:01 2021 +0200 @@ -34,7 +34,7 @@ namespace OrthancDatabases { - Dictionary::~Dictionary() + void Dictionary::Clear() { for (Values::iterator it = values_.begin(); it != values_.end(); ++it) @@ -42,8 +42,10 @@ assert(it->second != NULL); delete it->second; } + + values_.clear(); } - + bool Dictionary::HasKey(const std::string& key) const { diff -r dd4b0edd1661 -r 87f0e29a1dc1 Framework/Common/Dictionary.h --- a/Framework/Common/Dictionary.h Fri Jul 09 17:23:24 2021 +0200 +++ b/Framework/Common/Dictionary.h Mon Jul 12 09:40:01 2021 +0200 @@ -36,7 +36,12 @@ Values values_; public: - ~Dictionary(); + ~Dictionary() + { + Clear(); + } + + void Clear(); bool HasKey(const std::string& key) const; diff -r dd4b0edd1661 -r 87f0e29a1dc1 MySQL/Plugins/MySQLIndex.cpp --- a/MySQL/Plugins/MySQLIndex.cpp Fri Jul 09 17:23:24 2021 +0200 +++ b/MySQL/Plugins/MySQLIndex.cpp Mon Jul 12 09:40:01 2021 +0200 @@ -352,6 +352,12 @@ DatabaseManager& manager, int64_t id) { + /** + * Contrarily to PostgreSQL and SQLite, the MySQL dialect doesn't + * support cascaded delete inside the same table. This has to be + * manually reimplemented. + **/ + ClearDeletedFiles(manager); // Recursive exploration of resources to be deleted, from the "id"