# HG changeset patch # User Sebastien Jodogne # Date 1764163433 -3600 # Node ID 05d20326b33443566a7ebe024e572f6e957428c2 # Parent 0a9a6f5b81575b24b8ecdded5b78d1bb75986bd1# Parent da9d68c3bf6ba3776fdf47c1416722f69555c05d integration mainline->pg-next-699 diff -r 0a9a6f5b8157 -r 05d20326b334 Framework/Plugins/DatabaseBackendAdapterV4.cpp diff -r 0a9a6f5b8157 -r 05d20326b334 Framework/PostgreSQL/PostgreSQLParameters.cpp --- 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 { diff -r 0a9a6f5b8157 -r 05d20326b334 Framework/PostgreSQL/PostgreSQLParameters.h --- 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; diff -r 0a9a6f5b8157 -r 05d20326b334 PostgreSQL/NEWS --- 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: diff -r 0a9a6f5b8157 -r 05d20326b334 Resources/Orthanc/Plugins/OrthancPluginCppWrapper.cpp --- 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(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(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); } } } diff -r 0a9a6f5b8157 -r 05d20326b334 TODO --- 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 ----