On 2022/01/28 14:07, r.takahash...@fujitsu.com wrote:
I think %c of log_line_prefix (Session ID) is also useful for
postgres_fdw.application_name.
Therefore, how about adding both %c (Session ID) and %C (cluster_name)?
+1
Attached is the updated version of the patch. It adds those escape sequences %c
and %C.
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..af38e956e7 100644
--- a/contrib/postgres_fdw/option.c
+++ b/contrib/postgres_fdw/option.c
@@ -489,6 +489,12 @@ process_pgfdw_appname(const char *appname)
case 'a':
appendStringInfoString(&buf, application_name);
break;
+ case 'c':
+ appendStringInfo(&buf, "%lx.%x", (long)
(MyStartTime), MyProcPid);
+ 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..17cd90ab12 100644
--- a/doc/src/sgml/postgres-fdw.sgml
+++ b/doc/src/sgml/postgres-fdw.sgml
@@ -983,6 +983,20 @@ 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>
+ Session ID on local server
+ (see <xref linkend="guc-log-line-prefix"/> for details)
+ </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;