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

Поиск
Список
Период
Сортировка
Искать

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>
Дата:
The following bug has been logged on the website:

Bug reference:      19740
Logged by:          Shallow
Email address:      theshallow27@gmail.com
PostgreSQL version: 18.6
Operating system:   Linux
Description:        

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.




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

От:
Laurenz Albe <laurenz.albe@cybertec.at>
Дата:
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


FAQ