Re: BUG #19740: `has_language_privilege` returns TRUE for a nonexistent language OID when the user is a superuser

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: theshallow27(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19740: `has_language_privilege` returns TRUE for a nonexistent language OID when the user is a superuser
Date: 2026-10-04 13:39:32
Message-ID: c886cc0645ac17f6fe3d5b155e01d1be22bd6c97.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-bugs by date

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