From 6e0cb3dec10e460288d68a128e3d79d16a230cdb Mon Sep 17 00:00:00 2001
From: Fujii Masao
Date: Fri, 24 Dec 2021 16:55:11 +0900
Subject: postgres_fdw: Allow postgres_fdw.application_name to include escape
sequences.
application_name that used when postgres_fdw establishes a connection to
a foreign server can be specified in either or both a connection parameter
of a server object and GUC postgres_fdw.application_name. This commit
allows those parameters to include escape sequences that begins with
% character. Then postgres_fdw replaces those escape sequences with
status information. For example, %d and %u are replaced with user name
and database name in local server, respectively. This feature enables us
to add information more easily to track remote transactions or queries,
into application_name of a remote connection.
Author: Hayato Kuroda
Reviewed-by: Kyotaro Horiguchi, Masahiro Ikeda, Hou Zhijie, Fujii Masao
Discussion: https://postgr.es/m/TYAPR01MB5866FAE71C66547C64616584F5EB9@TYAPR01MB5866.jpnprd01.prod.outlook.com
Discussion: https://postgr.es/m/TYCPR01MB5870D1E8B949DAF6D3B84E02F5F29@TYCPR01MB5870.jpnprd01.prod.outlook.com
---
doc/src/sgml/postgres-fdw.sgml | 67 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 66 insertions(+), 1 deletion(-)
(limited to 'doc/src/sgml/postgres-fdw.sgml')
diff --git a/doc/src/sgml/postgres-fdw.sgml b/doc/src/sgml/postgres-fdw.sgml
index 0c55e0f0fd5..41cdb9ea1b5 100644
--- a/doc/src/sgml/postgres-fdw.sgml
+++ b/doc/src/sgml/postgres-fdw.sgml
@@ -130,6 +130,20 @@
server encoding)
+
+
+ application_name - this may appear in
+ either or both a connection and
+ .
+ If both are present, postgres_fdw.application_name
+ overrides the connection setting.
+ Unlike libpq,
+ postgres_fdw allows
+ application_name to include
+ escape sequences
.
+ See for details.
+
+
fallback_application_name (always set to
@@ -920,7 +934,7 @@ postgres=# SELECT postgres_fdw_disconnect_all();
Configuration Parameters
-
+
postgres_fdw.application_name (string)
@@ -946,6 +960,57 @@ postgres=# SELECT postgres_fdw_disconnect_all();
marks (?).
See for details.
+
+
+ % characters begin escape sequences
+ that are replaced with status information as outlined below.
+ Unrecognized escapes are ignored. Other characters are copied straight
+ to the application name. Note that it's not allowed to specify a
+ plus/minus sign or a numeric literal after the %
+ and before the option, for alignment and padding.
+
+
+
+
+
+
+ Escape
+ Effect
+
+
+
+
+ %a
+ Application name in local server
+
+
+ %u
+ User name in local server
+
+
+ %d
+ Database name in local server
+
+
+ %p
+ Process ID of backend in local server
+
+
+ %%
+ Literal %
+
+
+
+
+
+
+ For example, suppose user local_user establishes
+ a connection from database local_db to
+ foreign_db as user foreign_user,
+ the setting 'db=%d, user=%u' is replaced with
+ 'db=local_db, user=local_user'.
+
+
--
cgit v1.2.3