Skip to content

Commit 091bda0

Browse files
committed
Add collations to information_schema.usage_privileges
This is faked information like for domains.
1 parent 43bdf35 commit 091bda0

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

doc/src/sgml/information_schema.sgml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,7 +3560,7 @@ ORDER BY c.ordinal_position;
35603560
<row>
35613561
<entry><literal>object_type</literal></entry>
35623562
<entry><type>character_data</type></entry>
3563-
<entry><literal>DOMAIN</literal> or <literal>FOREIGN DATA WRAPPER</literal> or <literal>FOREIGN SERVER</literal></entry>
3563+
<entry><literal>COLLATION</literal> or <literal>DOMAIN</literal> or <literal>FOREIGN DATA WRAPPER</literal> or <literal>FOREIGN SERVER</literal></entry>
35643564
</row>
35653565

35663566
<row>
@@ -5497,15 +5497,15 @@ ORDER BY c.ordinal_position;
54975497
<literal>USAGE</literal> privileges granted on various kinds of
54985498
objects to a currently enabled role or by a currently enabled role.
54995499
In <productname>PostgreSQL</productname>, this currently applies to
5500-
domains, foreign-data wrappers, and foreign servers. There is one
5500+
collations, domains, foreign-data wrappers, and foreign servers. There is one
55015501
row for each combination of object, grantor, and grantee.
55025502
</para>
55035503

55045504
<para>
5505-
Since domains do not have real privileges
5505+
Since collations and domains do not have real privileges
55065506
in <productname>PostgreSQL</productname>, this view shows implicit
55075507
non-grantable <literal>USAGE</literal> privileges granted by the
5508-
owner to <literal>PUBLIC</literal> for all domains. The other
5508+
owner to <literal>PUBLIC</literal> for all collations and domains. The other
55095509
object types, however, show real privileges.
55105510
</para>
55115511

@@ -5556,7 +5556,7 @@ ORDER BY c.ordinal_position;
55565556
<row>
55575557
<entry><literal>object_type</literal></entry>
55585558
<entry><type>character_data</type></entry>
5559-
<entry><literal>DOMAIN</literal> or <literal>FOREIGN DATA WRAPPER</literal> or <literal>FOREIGN SERVER</literal></entry>
5559+
<entry><literal>COLLATION</literal> or <literal>DOMAIN</literal> or <literal>FOREIGN DATA WRAPPER</literal> or <literal>FOREIGN SERVER</literal></entry>
55605560
</row>
55615561

55625562
<row>

src/backend/catalog/information_schema.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,27 @@ GRANT SELECT ON triggers TO PUBLIC;
20192019

20202020
CREATE VIEW usage_privileges AS
20212021

2022+
/* collations */
2023+
-- Collations have no real privileges, so we represent all collations with implicit usage privilege here.
2024+
SELECT CAST(u.rolname AS sql_identifier) AS grantor,
2025+
CAST('PUBLIC' AS sql_identifier) AS grantee,
2026+
CAST(current_database() AS sql_identifier) AS object_catalog,
2027+
CAST(n.nspname AS sql_identifier) AS object_schema,
2028+
CAST(c.collname AS sql_identifier) AS object_name,
2029+
CAST('COLLATION' AS character_data) AS object_type,
2030+
CAST('USAGE' AS character_data) AS privilege_type,
2031+
CAST('NO' AS yes_or_no) AS is_grantable
2032+
2033+
FROM pg_authid u,
2034+
pg_namespace n,
2035+
pg_collation c
2036+
2037+
WHERE u.oid = c.collowner
2038+
AND c.collnamespace = n.oid
2039+
AND c.collencoding = (SELECT encoding FROM pg_catalog.pg_database WHERE datname = pg_catalog.current_database())
2040+
2041+
UNION ALL
2042+
20222043
/* domains */
20232044
-- Domains have no real privileges, so we represent all domains with implicit usage privilege here.
20242045
SELECT CAST(u.rolname AS sql_identifier) AS grantor,

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