RE: Allow pg_read_all_stats to read replication origin status

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Virender Singla' <virender(dot)cse(at)gmail(dot)com>, Shubhra Jain <shubhra(dot)jain(at)ksolves(dot)com>, Dilip Kumar <DilipBalaut(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Allow pg_read_all_stats to read replication origin status
Date: 2026-11-18 06:51:48
Message-ID: OS7PR01MB1831721C975AFD68E12BD64B2F57A2@OS7PR01MB18317.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Thanks for the discussion and sorry for the late reply. It seems OK to grant to
pg_read_all_stats role.

I cannot find examples to grant only for pg_monitor role in system views.
Some functions which report file name, like pg_ls_logdir and pg_ls_replslotdir(),
are granted for pg_monitor but pg_replication_origin_status is bit different
from them. So it seems not appropriate for us.
Regarding the PUBLIC/pg_read_all_stats options, actually I cannot come up
with good reasons to choose them but we can go with the conservative approach.
For now let's not to export PUBLIC.

Few comments for your patch:

01.
```
+GRANT EXECUTE ON FUNCTION pg_show_replication_origin_status() TO pg_read_all_stats;
```
I cannot find existing examples to GRANT EXECUTION in the file. Per my quick
lookup it's controled under the pg_proc.dat.

02.
```
+SELECT has_function_privilege('regress_readallstats','pg_show_replication_origin_status()','EXECUTE'); -- no
```
Do we have to check the internal function? E.g., a view pg_dsm_registry_allocations
is a wrapper of pg_get_dsm_registry_allocations but the latter one is not tested.

Best regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nitin Jadhav 2026-11-18 06:53:30 Re: [PATCH] Check interrupts while draining received WAL
Previous Message Bertrand Drouvot 2026-11-18 06:43:47 Re: Add a hook for handling logical decoding messages on subscribers.