Re: Add a permission check to pg_stat_get_backend_subxact() - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Add a permission check to pg_stat_get_backend_subxact()
Date
Msg-id aqec3MF_GDsMdadl@paquier.xyz
Whole thread
In response to Re: Add a permission check to pg_stat_get_backend_subxact()  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Add a permission check to pg_stat_get_backend_subxact()
List pgsql-hackers
On Sat, Sep 12, 2026 at 08:43:28AM -0400, shihao zhong wrote:
> Thanks for committing that, I will not include 0001 in the following emails.

Fixed the subxact_overflow -> subxact_overflowed, as that's
independent.

> 1. The first test block ran as superuser, so the owner branch of
>   HAS_PGSTAT_PERMISSIONS() was never exercised: with "userid" forced to
>   InvalidOid the test still passed.  The block now grants the test role
>   membership in the session's role instead.  With that, forcing userid
>   to InvalidOid fails the test, and removing the checks fails the
>   "unrelated role" block.
>
> 2. The doc paragraph above the per-backend table said the functions
>   "return NULL", but activity/wait_event return "<insufficient
>   privilege>" and the SRFs return no rows.  Reworded.
>
> 3. Commit message: noted that processes owned by no role (autovacuum
>   workers, WAL writer, ...) are now visible only to superusers and
>   pg_read_all_stats, as in pg_stat_activity, and that no backpatch is
>   done.

That seems globally sensible, at quick glance.  I am also adding
Bertrand Drouvot in CC to comment about this change, as he has worked
on three of these functions.

@Bertrand, what do you think?
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: Try a presorted outer path when referenced by an ORDER BY prefix
Next
From: Michael Paquier
Date:
Subject: Re: Translation of the NextOID message in pg_controldata