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