Goal Find foreign servers that do not have any associated user mappings. "A user mapping typically encapsulates connection information that a foreign-data wrapper uses together with the information encapsulated by a foreign server to access an external data resource."
Notes The query takes into account that in case of some foreign data wrappers (like file_fdw) a mapping is not needed.
Type Problem detection (Each row in the result could represent a flaw in the design)
Reliability Medium (Medium number of false-positive results)
License MIT License
Data Source INFORMATION_SCHEMA+system catalog
SQL Query
SELECT foreign_server_name, foreign_data_wrapper_name
FROM INFORMATION_SCHEMA.foreign_servers AS fs
WHERE NOT EXISTS (SELECT *
FROM pg_user_mappings
WHERE pg_user_mappings.srvname=fs.foreign_server_name)
AND foreign_data_wrapper_name<>'file_fdw'
ORDER BY foreign_server_name;

Collections

This query belongs to the following collections:

NameDescription
Find problems automaticallyQueries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .
Categories

This query is classified under the following categories:

NameDescription
Distributed databaseQueries of this category provide information about the foreign table mechanism.