Re: Add pg_ownerships and pg_privileges system views

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: "Alvaro Herrera" <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add pg_ownerships and pg_privileges system views
Date: 2024-10-21 11:31:37
Message-ID: f67907c3-7202-4f3a-901a-045ad9aca284@app.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 21, 2024, at 11:42, Alvaro Herrera wrote:
> ... actually, the "AND pg_shdepend.dbid = ( SELECT pg_database_1.oid
> ...)" part of this is useless, because you already had that in the ON
> condition of the original join to pg_database. So, apologies for the
> noise there. TBH I don't see why you put that in the JOIN ON condition
> instead of WHERE, but anyway you don't need to add a new condition for
> it. I guess I'd do it like this for clarity:
>
> FROM pg_catalog.pg_shdepend
> JOIN pg_catalog.pg_database ON pg_database.oid =
> pg_shdepend.dbid
> JOIN pg_catalog.pg_authid ON pg_authid.oid =
> pg_shdepend.refobjid
> LATERAL pg_catalog.pg_identify_object(pg_shdepend.classid,
> pg_shdepend.objid, pg_shdepend.objsubid) AS identify,
> LATERAL
> pg_catalog.aclexplode(pg_catalog.pg_get_acl(pg_shdepend.classid,
> pg_shdepend.objid, pg_shdepend.objsubid)) AS aclexplode
> WHERE pg_shdepend.deptype = 'a' AND
> pg_shdepend.refclassid = 'pg_catalog.pg_authid'::pg_catalog.regclass
> AND
> pg_database.datname = pg_catalog.current_database()
>
> ... but since these are inner joins, this might be a matter of style.
> (I did add a couple of schema-qualifications there.)

Ahh, right, that's nicer, thanks for fixing.

New patch attached.

I also fixed pg_ownerships in the same way, moving the `pg_catalog.pg_database.datname = pg_catalog.current_database()` to the WHERE clause instead.

/Joel

Attachment Content-Type Size
v5-0001-Add-pg_ownerships-and-pg_privileges-system-views.patch application/octet-stream 17.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Кириллов Вячеслав 2024-10-21 12:00:41 Question about VACUUM behavior with sub-transactions in stored procedures
Previous Message Alexander Korotkov 2024-10-21 11:30:41 Re: type cache cleanup improvements