From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: pgsql-hackers@postgresql.org
Subject: Support escape sequence for cluster_name in postgres_fdw.application_name
Date: Tue, 25 Jan 2022 16:02:39 +0900
Message-ID: <1041dc9a-c976-049f-9f14-e7d94c29c4b2@oss.nttdata.com> (raw)
Hi,
Commit 6e0cb3dec1 allowed postgres_fdw.application_name to include escape sequences %a (application name), %d (database name), %u (user name) and %p (pid). In addition to them, I'd like to support the escape sequence (e.g., %C) for cluster name there. This escape sequence is helpful to investigate where each remote transactions came from. Thought?
Patch attached.
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Attachments:pgfdw_appname_cluster_name_v1.patch (text/plain, 1.6K) downloaddiff --git a/contrib/postgres_fdw/option.c b/contrib/postgres_fdw/option.cindex fc3ce6a53a..4120c21d09 100644--- a/contrib/postgres_fdw/option.c+++ b/contrib/postgres_fdw/option.c@@ -489,6 +489,9 @@ process_pgfdw_appname(const char *appname)
case 'a':
appendStringInfoString(&buf, application_name);
break;
+ case 'C':+ appendStringInfoString(&buf, cluster_name);+ break;
case 'd':
appendStringInfoString(&buf, MyProcPort->database_name);
break;
diff --git a/doc/src/sgml/postgres-fdw.sgml b/doc/src/sgml/postgres-fdw.sgmlindex 2bb31f1125..d7f545958c 100644--- a/doc/src/sgml/postgres-fdw.sgml+++ b/doc/src/sgml/postgres-fdw.sgml@@ -983,6 +983,13 @@ postgres=# SELECT postgres_fdw_disconnect_all();
<entry><literal>%a</literal></entry>
<entry>Application name on local server</entry>
</row>
+ <row>+ <entry><literal>%C</literal></entry>+ <entry>+ Cluster name in local server+ (see <xref linkend="guc-cluster-name"/> for details)+ </entry>+ </row>
<row>
<entry><literal>%u</literal></entry>
<entry>User name on local server</entry>
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.hindex 6bb81707b0..f1bfe79feb 100644--- a/src/include/utils/guc.h+++ b/src/include/utils/guc.h@@ -271,7 +271,7 @@ extern int temp_file_limit;
extern int num_temp_buffers;
-extern char *cluster_name;+extern PGDLLIMPORT char *cluster_name;
extern PGDLLIMPORT char *ConfigFileName;
extern char *HbaFileName;
extern char *IdentFileName;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: masao.fujii@oss.nttdata.com
Subject: Re: Support escape sequence for cluster_name in postgres_fdw.application_name
In-Reply-To: <1041dc9a-c976-049f-9f14-e7d94c29c4b2@oss.nttdata.com>
References: <1041dc9a-c976-049f-9f14-e7d94c29c4b2@oss.nttdata.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox