From 4f08ab55457751308ffd8d33e82155758cd0e304 Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Wed, 18 Sep 2024 12:51:48 +0900 Subject: postgres_fdw: Extend postgres_fdw_get_connections to return user name. This commit adds a "user_name" output column to the postgres_fdw_get_connections function, returning the name of the local user mapped to the foreign server for each connection. If a public mapping is used, it returns "public." This helps identify postgres_fdw connections more easily, such as determining which connections are invalid, closed, or used within the current transaction. No extension version bump is needed, as commit c297a47c5f already handled it for v18~. Author: Hayato Kuroda Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/b492a935-6c7e-8c08-e485-3c1d64d7d10f@oss.nttdata.com --- doc/src/sgml/postgres-fdw.sgml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/postgres-fdw.sgml b/doc/src/sgml/postgres-fdw.sgml index 468724e94ef..627bb5ab5cc 100644 --- a/doc/src/sgml/postgres-fdw.sgml +++ b/doc/src/sgml/postgres-fdw.sgml @@ -779,7 +779,8 @@ OPTIONS (ADD password_required 'false'); postgres_fdw_get_connections( IN check_conn boolean DEFAULT false, OUT server_name text, - OUT valid boolean, OUT used_in_xact boolean, OUT closed boolean) + OUT user_name text, OUT valid boolean, OUT used_in_xact boolean, + OUT closed boolean) returns setof record @@ -806,10 +807,12 @@ OPTIONS (ADD password_required 'false'); Example usage of the function: - server_name | valid | used_in_xact | closed --------------+-------+--------------+-------- - loopback1 | t | t | - loopback2 | f | t | +postgres=# SELECT * FROM postgres_fdw_get_connections(true); + server_name | user_name | valid | used_in_xact | closed +-------------+-----------+-------+--------------+-------- + loopback1 | postgres | t | t | f + loopback2 | public | t | t | f + loopback3 | | f | t | f The output columns are described in . @@ -836,6 +839,16 @@ OPTIONS (ADD password_required 'false'); invalid), this will be NULL. + + user_name + text + + Name of the local user mapped to the foreign server of this + connection, or public if a public mapping is used. + If the user mapping is dropped but the connection remains open + (i.e., marked as invalid), this will be NULL. + + valid boolean -- cgit v1.2.3