Hi all, On Fri, Dec 4, 2026 at 10:15 AM Virender Singla <[email protected]> wrote: > > Thanks for taking a look, I attached the v3 version with the refinements. > > > 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. > > Looks like I was working on an older copy. Since commit f95d73ed433 > ("Simplify creation of built-in functions with non-default ACLs", > [1]), non-default ACLs for built-in functions are moved from > system_functions.sql/system_views.sql. v3 follows that now. > > > 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. > > I dropped the has_function_privilege() checks. As with the other > pg_read_all_stats views, the SELECT COUNT(*) on the view run as a > member of pg_read_all_stats already exercises EXECUTE on the backing > function > > [1] https://postgr.es/m/[email protected] >
I have reviewed and tested the updated patch. The proposed changes give the intended results. Granting SELECT access on pg_replication_origin_status to pg_read_all_stats, along with EXECUTE permission on the underlying pg_show_replication_origin_status() function, provides the required access while retaining the existing restriction for ordinary users. I also verified that members of pg_read_all_stats can successfully query the view, members of pg_monitor can access the view through their membership in pg_read_all_stats, ordinary users without the required role membership continue to receive a permission-denied error, The underlying function can be executed by members of pg_read_all_stats and the focused privileges regression test and the complete PostgreSQL regression test suite pass successfully. The implementation also addresses the review comments discussed in the thread. The function's EXECUTE privilege is now defined in pg_proc.dat instead of system_views.sql and the separate has_function_privilege() checks have been removed, as querying the view itself verifies the function's execution privilege.. Overall, I did not identify any issues in the reviewed changes. The patch looks good to me based on the testing performed. Regards, Solai
