]> granicus.if.org Git - postgresql/commitdiff
Show schemas in information_schema.schemata that the current has access to
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 10 Sep 2013 02:25:37 +0000 (22:25 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Tue, 10 Sep 2013 02:25:37 +0000 (22:25 -0400)
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
src/backend/catalog/information_schema.sql

index 3ac555dad37583258eeac46103a04f01a333d600..22e17bb5e6917dbeaaf3931454905a1ddb7b2c20 100644 (file)
@@ -4547,8 +4547,9 @@ ORDER BY c.ordinal_position;
   <title><literal>schemata</literal></title>
 
   <para>
-   The view <literal>schemata</literal> contains all schemas in the
-   current database that are owned by a currently enabled role.
+   The view <literal>schemata</literal> contains all schemas in the current
+   database that the current user has access to (by way of being the owner or
+   having some privilege).
   </para>
 
   <table>
index 95f267f224ece107735de7e2aa865ea8464b693b..c5f7a8b21008b422b9ec47a0dbe9389dfb6a6bdd 100644 (file)
@@ -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;