Re: Add a permission check to pg_stat_get_backend_subxact()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: shihao zhong <zhong950419(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add a permission check to pg_stat_get_backend_subxact()
Date: 2026-09-11 07:53:06
Message-ID: aqOzYr0It5sP7eFF@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 10, 2026 at 05:47:36PM +0200, Jim Jones wrote:
> On 08/09/2026 02:33, shihao zhong wrote:
> pg_stat_get_backend_wal, pg_stat_get_backend_io, and
> pg_stat_get_backend_lock also lack this check. Out of scope here, but
> perhaps worth a followup patch?

Hmm, yeah. You have a consistency point here. None of these stats
are critical in any way, but cleaning up all that on HEAD shoulds like
a good thing to do, while we are on it. Let's group all that in a
single patch. All these functions treat similar backend-level stats.

> I believe the tests should also cover a non-superuser with explicit
> pg_read_all_stats permission (see 0002 attached)

Yep. Let's make that also cheaper: one role for all of the functions.

> The C tuple descriptor still says "subxact_overflow" -- most likely the
> source of the confusion.
>
> TupleDescInitEntry(tupdesc, (AttrNumber) 2, "subxact_overflow",
> BOOLOID, -1, 0);

Ahah, nice catch. The value that primes (reported back to the user)
is not the one set in the TupleDesc but the one defined in pg_proc.dat.

Could you group all your findings in a single patch? The doc entry
needs to be at least backpatched, mentioning "overflow" instead of
"overflowed" is not correct.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2026-09-11 07:55:41 Re: PSQL schema "describe" \dn is not escaping quotes
Previous Message Ayush Tiwari 2026-09-11 07:45:34 Re: [BUG] ON CONFLICT DO UPDATE SET x = EXCLUDED.<virtual-generated-column> errors or silently writes NULL