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
diff --git a/contrib/postgres_fdw/option.c b/contrib/postgres_fdw/option.c
index 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.sgml
index 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.h
index 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 via email to