diff options
Diffstat (limited to 'contrib/postgres_fdw/expected')
-rw-r--r-- | contrib/postgres_fdw/expected/postgres_fdw.out | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out index 82fdc0e26fc..212434711e3 100644 --- a/contrib/postgres_fdw/expected/postgres_fdw.out +++ b/contrib/postgres_fdw/expected/postgres_fdw.out @@ -10464,10 +10464,10 @@ drop cascades to foreign table ft7 -- 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; - server_name | valid | used_in_xact --------------+-------+-------------- - loopback | f | t - | f | t + server_name | valid | used_in_xact | closed +-------------+-------+--------------+-------- + loopback | f | t | + | f | t | (2 rows) -- The invalid connections get closed in pgfdw_xact_callback during commit. @@ -12286,3 +12286,49 @@ ANALYZE analyze_table; -- cleanup DROP FOREIGN TABLE analyze_ftable; DROP TABLE analyze_table; +-- =================================================================== +-- test for postgres_fdw_get_connections function with check_conn = true +-- =================================================================== +-- Disable debug_discard_caches in order to manage remote connections +SET debug_discard_caches TO '0'; +-- The text of the error might vary across platforms, so only show SQLSTATE. +\set VERBOSITY sqlstate +SELECT 1 FROM postgres_fdw_disconnect_all(); + ?column? +---------- + 1 +(1 row) + +ALTER SERVER loopback OPTIONS (SET application_name 'fdw_conn_check'); +SELECT 1 FROM ft1 LIMIT 1; + ?column? +---------- + 1 +(1 row) + +-- Since the remote server is still connected, "closed" should be FALSE, +-- or NULL if the connection status check is not available. +SELECT CASE WHEN closed IS NOT true THEN 1 ELSE 0 END + FROM postgres_fdw_get_connections(true); + case +------ + 1 +(1 row) + +-- After terminating the remote backend, since the connection is closed, +-- "closed" should be TRUE, or NULL if the connection status check +-- is not available. +DO $$ BEGIN +PERFORM pg_terminate_backend(pid, 180000) FROM pg_stat_activity + WHERE application_name = 'fdw_conn_check'; +END $$; +SELECT CASE WHEN closed IS NOT false THEN 1 ELSE 0 END + FROM postgres_fdw_get_connections(true); + case +------ + 1 +(1 row) + +-- Clean up +\set VERBOSITY default +RESET debug_discard_caches; |