mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
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
This commit is contained in:
@ -3382,9 +3382,11 @@ SELECT server_name FROM postgres_fdw_get_connections() ORDER BY 1;
|
||||
ALTER SERVER loopback OPTIONS (ADD use_remote_estimate 'off');
|
||||
DROP SERVER loopback3 CASCADE;
|
||||
-- List all the existing cached connections. loopback and loopback3
|
||||
-- should be output as invalid connections. Also the server name for
|
||||
-- loopback3 should be NULL because the server was dropped.
|
||||
SELECT * FROM postgres_fdw_get_connections() ORDER BY 1;
|
||||
-- should be output as invalid connections. Also the server name and user name
|
||||
-- for loopback3 should be NULL because both server and user mapping were
|
||||
-- dropped.
|
||||
SELECT server_name, user_name = CURRENT_USER as "user_name = CURRENT_USER", valid, used_in_xact, closed
|
||||
FROM postgres_fdw_get_connections() ORDER BY 1;
|
||||
-- The invalid connections get closed in pgfdw_xact_callback during commit.
|
||||
COMMIT;
|
||||
-- All cached connections were closed while committing above xact, so no
|
||||
|
Reference in New Issue
Block a user