Re: event triggers in 9.3.4

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: "Vasudevan, Ramya" <ramya(dot)vasudevan(at)classmates(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: event triggers in 9.3.4
Date: 2014-07-24 00:40:01
Message-ID: 53D055E1.10609@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/23/2014 05:22 PM, Vasudevan, Ramya wrote:
> I set up the following to log all DDLs executed in the database:
>
> CREATE TABLE log_ddl_info(ddl_tag text, ddl_event text, ddl_time timestamp);
>
> CREATE OR REPLACE FUNCTION log_ddl_execution()
>
> RETURNS event_trigger AS $$
>
> DECLARE
>
> insertquery TEXT;
>
> BEGIN
>
> insertquery := 'INSERT INTO log_ddl_info VALUES (''' || tg_tag ||''',
> ''' || tg_event || ''', statement_timestamp())';
>
> EXECUTE insertquery;
>
> RAISE NOTICE 'Recorded execution of command % with event %', tg_tag,
> tg_event;
>
> END;
>
> $$ LANGUAGE plpgsql;
>
> CREATE EVENT TRIGGER log_ddl_info_start ON ddl_command_start EXECUTE
> PROCEDURE log_ddl_execution();
>
> CREATE EVENT TRIGGER log_ddl_info_end ON ddl_command_end EXECUTE
> PROCEDURE log_ddl_execution();
>
> Is there a way to log the object name (or the oid) in the function?

The only thing I see is for dropped objects:

http://www.postgresql.org/docs/9.4/static/functions-event-triggers.html

pg_event_trigger_dropped_objects()

>
> Thank you,
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message matt 2014-07-24 00:41:08 Re: Complex Recursive Query
Previous Message Vasudevan, Ramya 2014-07-24 00:22:08 event triggers in 9.3.4