Mercurial > hg > orthanc-databases
changeset 760:05d20326b334 pg-next-699
integration mainline->pg-next-699
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Wed, 26 Nov 2025 14:23:53 +0100 |
| parents | 0a9a6f5b8157 (current diff) da9d68c3bf6b (diff) |
| children | 75ab74d68f08 |
| files | Framework/Plugins/DatabaseBackendAdapterV4.cpp Framework/PostgreSQL/PostgreSQLParameters.cpp PostgreSQL/NEWS Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp |
| diffstat | 5 files changed, 56 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/PostgreSQL/PostgreSQLParameters.cpp Wed Nov 19 18:45:48 2025 +0100 +++ b/Framework/PostgreSQL/PostgreSQLParameters.cpp Wed Nov 26 14:23:53 2025 +0100 @@ -101,6 +101,7 @@ lock_ = configuration.GetBooleanValue("Lock", true); // Use locking by default SetSchema(configuration.GetStringValue("Schema", "public")); + SetApplicationName(configuration.GetStringValue("ApplicationName", "")); isVerboseEnabled_ = configuration.GetBooleanValue("EnableVerboseLogs", false); allowInconsistentChildCounts_ = configuration.GetBooleanValue("AllowInconsistentChildCounts", false); @@ -211,6 +212,11 @@ Orthanc::Toolbox::ToLowerCase(schema_, schema); } + void PostgreSQLParameters::SetApplicationName(const std::string& applicationName) + { + applicationName_ = applicationName; + } + const std::string PostgreSQLParameters::GetReadWriteTransactionStatement() const { switch (isolationMode_) @@ -259,10 +265,15 @@ target += " password=" + password_; } - if (database_.size() > 0) + if (!database_.empty()) { target += " dbname=" + database_; } + + if (!applicationName_.empty()) + { + target += " application_name=" + applicationName_; + } } else {
--- a/Framework/PostgreSQL/PostgreSQLParameters.h Wed Nov 19 18:45:48 2025 +0100 +++ b/Framework/PostgreSQL/PostgreSQLParameters.h Wed Nov 26 14:23:53 2025 +0100 @@ -46,6 +46,7 @@ std::string password_; std::string database_; std::string schema_; + std::string applicationName_; std::string uri_; bool ssl_; bool lock_; @@ -112,6 +113,13 @@ return schema_; } + void SetApplicationName(const std::string& applicationName); + + const std::string& GetApplicationName() const + { + return applicationName_; + } + void SetSsl(bool ssl) { ssl_ = ssl;
--- a/PostgreSQL/NEWS Wed Nov 19 18:45:48 2025 +0100 +++ b/PostgreSQL/NEWS Wed Nov 26 14:23:53 2025 +0100 @@ -22,6 +22,9 @@ schema or that you install the pg_trgm extension manually in the public schema. The plugin now calls 'SET search_path TO $schema' when opening a new connection to the DB. +* New configuration "ApplicationName" (default value is empty) that is copied in + the application_name argument in the connection string. This name is used to + identify the origin of queries in statistics and logs in the PostgreSQL server. * SDK: Added support for ReserveQueueValue and AcknowledgeQueueValue (new in SDK 1.12.10) Maintenance:
--- a/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Wed Nov 19 18:45:48 2025 +0100 +++ b/Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp Wed Nov 26 14:23:53 2025 +0100 @@ -2720,32 +2720,42 @@ return; } - else if (state == "Running") + else if (state == "Running" || + state == "Pending" || + state == "Paused" || + state == "Retry") { continue; } - else if (!status.isMember("ErrorCode") || - status["ErrorCode"].type() != Json::intValue) + else if (state == "Failure") { - ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_InternalError); + if (!status.isMember("ErrorCode") || + status["ErrorCode"].type() != Json::intValue) + { + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_InternalError); + } + else + { + if (!status.isMember("ErrorDescription") || + status["ErrorDescription"].type() != Json::stringValue) + { + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(status["ErrorCode"].asInt()); + } + else + { + #if HAS_ORTHANC_EXCEPTION == 1 + throw Orthanc::OrthancException(static_cast<Orthanc::ErrorCode>(status["ErrorCode"].asInt()), + status["ErrorDescription"].asString()); + #else + ORTHANC_PLUGINS_LOG_ERROR("Exception while executing the job: " + status["ErrorDescription"].asString()); + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(status["ErrorCode"].asInt()); + #endif + } + } } else { - if (!status.isMember("ErrorDescription") || - status["ErrorDescription"].type() != Json::stringValue) - { - ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(status["ErrorCode"].asInt()); - } - else - { -#if HAS_ORTHANC_EXCEPTION == 1 - throw Orthanc::OrthancException(static_cast<Orthanc::ErrorCode>(status["ErrorCode"].asInt()), - status["ErrorDescription"].asString()); -#else - ORTHANC_PLUGINS_LOG_ERROR("Exception while executing the job: " + status["ErrorDescription"].asString()); - ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(status["ErrorCode"].asInt()); -#endif - } + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_InternalError); } } }
--- a/TODO Wed Nov 19 18:45:48 2025 +0100 +++ b/TODO Wed Nov 26 14:23:53 2025 +0100 @@ -64,6 +64,10 @@ - https://dev.mysql.com/doc/refman/8.0/en/index-btree-hash.html +* Add primary keys in DeletedFiles and DeletedResources + https://discourse.orthanc-server.org/t/missing-primary-keys-on-mysql/6307/3 + The patch has not been integrated yet because we need to handle DB schema upgrade -> to be done for the next release. + ---- ODBC ----
