# HG changeset patch # User Alain Mazy # Date 1760513279 -7200 # Node ID 5295d495a114de5eb2e1ee44f5c96d4d8ab73e49 # Parent 176e5dfbad433a60fa2c3a60d65816d4b401e118 PG: added ApplicationName diff -r 176e5dfbad43 -r 5295d495a114 Framework/PostgreSQL/PostgreSQLParameters.cpp --- a/Framework/PostgreSQL/PostgreSQLParameters.cpp Wed Oct 08 14:47:15 2025 +0200 +++ b/Framework/PostgreSQL/PostgreSQLParameters.cpp Wed Oct 15 09:27:59 2025 +0200 @@ -39,6 +39,7 @@ username_ = ""; password_ = ""; database_.clear(); + schema_ = "public"; uri_.clear(); ssl_ = false; lock_ = true; @@ -100,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); @@ -210,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_) @@ -258,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 176e5dfbad43 -r 5295d495a114 Framework/PostgreSQL/PostgreSQLParameters.h --- a/Framework/PostgreSQL/PostgreSQLParameters.h Wed Oct 08 14:47:15 2025 +0200 +++ b/Framework/PostgreSQL/PostgreSQLParameters.h Wed Oct 15 09:27:59 2025 +0200 @@ -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 176e5dfbad43 -r 5295d495a114 PostgreSQL/NEWS --- a/PostgreSQL/NEWS Wed Oct 08 14:47:15 2025 +0200 +++ b/PostgreSQL/NEWS Wed Oct 15 09:27:59 2025 +0200 @@ -20,6 +20,10 @@ 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. + Maintenance: * Now verifying the DatabasePatchLevel (revision) in another transaction than