From b34f8f409bec4921d260ac84668917f5fff04319 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 9 Sep 2013 22:25:37 -0400 Subject: [PATCH] Show schemas in information_schema.schemata that the current has access to Before, it would only show schemas that the current user owns. Per discussion, the new behavior is more useful and consistent for PostgreSQL. --- doc/src/sgml/information_schema.sgml | 5 +++-- src/backend/catalog/information_schema.sql | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/information_schema.sgml b/doc/src/sgml/information_schema.sgml index 3ac555dad3..22e17bb5e6 100644 --- a/doc/src/sgml/information_schema.sgml +++ b/doc/src/sgml/information_schema.sgml @@ -4547,8 +4547,9 @@ ORDER BY c.ordinal_position; <literal>schemata</literal> - The view schemata contains all schemas in the - current database that are owned by a currently enabled role. + The view schemata contains all schemas in the current + database that the current user has access to (by way of being the owner or + having some privilege). diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql index 95f267f224..c5f7a8b210 100644 --- a/src/backend/catalog/information_schema.sql +++ b/src/backend/catalog/information_schema.sql @@ -1502,7 +1502,9 @@ CREATE VIEW schemata AS CAST(null AS sql_identifier) AS default_character_set_name, CAST(null AS character_data) AS sql_path FROM pg_namespace n, pg_authid u - WHERE n.nspowner = u.oid AND pg_has_role(n.nspowner, 'USAGE'); + WHERE n.nspowner = u.oid + AND (pg_has_role(n.nspowner, 'USAGE') + OR has_schema_privilege(n.oid, 'CREATE, USAGE')); GRANT SELECT ON schemata TO PUBLIC;