Re: BUG #19740: `has_language_privilege` returns TRUE for a nonexistent language OID when the user is a superuser - Mailing list pgsql-bugs

From Laurenz Albe
Subject Re: BUG #19740: `has_language_privilege` returns TRUE for a nonexistent language OID when the user is a superuser
Date
Msg-id c886cc0645ac17f6fe3d5b155e01d1be22bd6c97.camel@cybertec.at
Whole thread
In response to BUG #19740: `has_language_privilege` returns TRUE for a nonexistent language OID when the user is a superuser  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
On Fri, 2026-10-02 at 22:38 +0000, PG Bug reporting form wrote:
> ostgreSQL version: 18.6
>
> For a nonexistent language OID, the implicit-current-user form returns TRUE
> when the current user is a superuser. An explicit non-superuser role returns
> NULL for the same missing OID. This makes the result depend on the role's
> superuser status even though the referenced language does not exist.
>
> **Reproduction:** Run as the default `postgres` superuser:
>
> ```sql
> SELECT NOT EXISTS (SELECT FROM pg_language WHERE oid = 0),
>        has_language_privilege(0::oid, 'USAGE'),
>        has_language_privilege('pg_monitor', 0::oid, 'USAGE');
> ```
>
> **Actual result:** `true | true | NULL`.
>
> **Expected result:** The privilege inquiry should return NULL for the
> missing
> language OID in both forms, matching the function's missing-object handling
> for non-superuser roles.

I agree that that is not so great.  Since this behavior is in the function
object_aclcheck_ext(), which is used by all the has_*_privilege functions,
the same oddity affects all those functions.

I think that would be easy to change, but I wonder if it is a good idea.
That bug hardly hurts: has_language_privilege() is typically not what you
use to find out if a procedural language exists or not.
And perhaps there is a misguided script somewhere out there that would
suddenly start to misbehave if a superuser no longer is reported as having
all privileges on non-existing objects.

Is it a real problem for you?

Yours,
Laurenz Albe



pgsql-bugs by date:

Previous
From: Kirill Reshke
Date:
Subject: Re: Backend crash (signal 11) in pg_trgm makesign() after ALTER TABLE ... SET STORAGE on a column with a gist_trgm_ops index
Next
From: Laurenz Albe
Date:
Subject: Re: BUG #19738: `uuidv7(interval)` rejects sub-millisecond timestamps within the final 48-bit millisecond