Re: SuperUser check in pg_stat_statements - Mailing list pgsql-hackers

From Feike Steenbergen
Subject Re: SuperUser check in pg_stat_statements
Date
Msg-id CAK_s-G0_vBtR=Safrja10d1oWo-cSsQiBRoVJYQOQUoJNQCHYg@mail.gmail.com
Whole thread Raw
In response to Re: SuperUser check in pg_stat_statements  (rajan <vgmonnet@gmail.com>)
List pgsql-hackers
You can create a Security Definer Funtion which can then be executed by then non-superuser monitoring role:

(Assuming you have a role monitoring and pg_stat_statements is installed in schema public)

    -- connected as a superuser
    CREATE FUNCTION pg_stat_statements()
    RETURNS SETOF pg_stat_statements
    LANGUAGE SQL
    SET search_path='public'
    SECURITY DEFINER
    AS
    $BODY$
    SELECT *
      FROM pg_stat_statements;
    $BODY$;

    REVOKE ALL ON FUNCTION pg_stat_statements() FROM public;
    GRANT EXECUTE ON FUNCTION pg_stat_statements() TO monitoring;

    -- connected as monitoring
    SELECT * FROM pg_stat_statements();

pgsql-hackers by date:

Previous
From: "Syed, Rahila"
Date:
Subject: Re: [PROPOSAL] VACUUM Progress Checker.
Next
From: David Rowley
Date:
Subject: Re: Parallel Aggregate