Skip to content

Commit b34f8f4

Browse files
committed
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.
1 parent 71901ab commit b34f8f4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

doc/src/sgml/information_schema.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4547,8 +4547,9 @@ ORDER BY c.ordinal_position;
45474547
<title><literal>schemata</literal></title>
45484548

45494549
<para>
4550-
The view <literal>schemata</literal> contains all schemas in the
4551-
current database that are owned by a currently enabled role.
4550+
The view <literal>schemata</literal> contains all schemas in the current
4551+
database that the current user has access to (by way of being the owner or
4552+
having some privilege).
45524553
</para>
45534554

45544555
<table>

src/backend/catalog/information_schema.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,9 @@ CREATE VIEW schemata AS
15021502
CAST(null AS sql_identifier) AS default_character_set_name,
15031503
CAST(null AS character_data) AS sql_path
15041504
FROM pg_namespace n, pg_authid u
1505-
WHERE n.nspowner = u.oid AND pg_has_role(n.nspowner, 'USAGE');
1505+
WHERE n.nspowner = u.oid
1506+
AND (pg_has_role(n.nspowner, 'USAGE')
1507+
OR has_schema_privilege(n.oid, 'CREATE, USAGE'));
15061508

15071509
GRANT SELECT ON schemata TO PUBLIC;
15081510

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy