pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Miles Elam <miles.elam@productops.com>
Cc: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: Event Triggers and GRANT/REVOKE
Date: Thu, 10 Oct 2019 08:07:39 -0700
Message-ID: <58abb5fa-ed73-2487-764b-1bf061ba0339@aklaver.com> (raw)
In-Reply-To: <CAALojA93Dmh=QP63S=CvLtEEPuFdB07Ca4rb6Y_7FB9Ndz3wFg@mail.gmail.com>
References: <CAALojA9YTg1GzECnTkSnpt7pStsXdhOM132mJt4FLQUC4eVsrg@mail.gmail.com>
	<80a52d0f-497b-daf5-c1b4-40dc1fad70d0@aklaver.com>
	<CAALojA93Dmh=QP63S=CvLtEEPuFdB07Ca4rb6Y_7FB9Ndz3wFg@mail.gmail.com>

On 10/9/19 3:20 PM, Miles Elam wrote:
> Using my example below from another thread, GRANTs and REVOKEs leave all 
> fields NULL except for command_tag (set to 'GRANT' or 'REVOKE'), 
> object_type (set to upper case target like 'TABLE'), and in_extension 
> (set to whatever is appropriate, but typically false).

 From the source:

https://doxygen.postgresql.org/event__trigger_8c.html#a4fc09f5b8231780b7f1abdd2a72f95a7

https://doxygen.postgresql.org/event__trigger_8c.html#a2b4e240a2c0aa9cfcc61f906af134913

Line 2185 case SCT_Grant

Looks like the information is never collected. The why is going to need 
an answer from a developer.


As to case it looks like GRANT/REVOKE use a different method of deriving 
the string then other commands, namely using stringify_adefprivs_objtype()


> 
> -----
> 
> CREATE TABLE IF NOT EXISTS ddl_info (
>    classid oid,
>    objid oid,
>    objsubid integer,
>    command_tag text,
>    object_type text,
>    schema_name text,
>    object_identity text,
>    in_extension bool,
>    transaction_id bigint NOT NULL DEFAULT txid_current(),
>    inserted timestamptz NOT NULL DEFAULT clock_timestamp()
> );
> 
> CREATE OR REPLACE FUNCTION ddl_log()
> RETURNS EVENT_TRIGGER
> LANGUAGE plpgsql AS $$
> BEGIN
>    INSERT INTO ddl_info (
>      classid, objid, objsubid, command_tag, object_type,
>      schema_name, object_identity, in_extension
>    )
>    SELECT
>      classid, objid, objsubid, command_tag, object_type,
>      schema_name, object_identity, in_extension
>    FROM pg_event_trigger_ddl_commands();
> END;
> $$;
> 
> CREATE EVENT TRIGGER aa_ddl_info ON ddl_command_end
> EXECUTE PROCEDURE ddl_log();
> 
> On Wed, Oct 9, 2019 at 2:27 PM Adrian Klaver <adrian.klaver@aklaver.com 
> <mailto:adrian.klaver@aklaver.com>> wrote:
> 
>     On 10/9/19 1:56 PM, Miles Elam wrote:
>      > GRANT and REVOKE trigger on a ddl_command_end event trigger but
>     don't
>      > provide any information beyond whether it was a table, schema,
>     function,
>      > etc. that was affected. No object IDs or the like are included. How
>      > would you find out which table had its ACLs modified?
> 
>     What is the code for trigger and function?
> 
>      >
>      > Also, why do grants and revokes have an object_type of 'TABLE'
>     instead
>      > of lower case names like 'table' for all other event types?
>      >
>      >
>      > Thanks,
>      >
>      > Miles Elam
>      >
> 
> 
>     -- 
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (4+ messages)

Message-ID: <58abb5fa-ed73-2487-764b-1bf061ba0339@aklaver.com>
Permalink:  ../58abb5fa-ed73-2487-764b-1bf061ba0339@aklaver.com/
Also on:    postgresql.org/message-id/58abb5fa-ed73-2487-764b-1bf061ba0339@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, miles.elam@productops.com
  Subject: Re: Event Triggers and GRANT/REVOKE
  In-Reply-To: <58abb5fa-ed73-2487-764b-1bf061ba0339@aklaver.com>
  References: <CAALojA9YTg1GzECnTkSnpt7pStsXdhOM132mJt4FLQUC4eVsrg@mail.gmail.com> <80a52d0f-497b-daf5-c1b4-40dc1fad70d0@aklaver.com> <CAALojA93Dmh=QP63S=CvLtEEPuFdB07Ca4rb6Y_7FB9Ndz3wFg@mail.gmail.com> <58abb5fa-ed73-2487-764b-1bf061ba0339@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox