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 [email protected] -- Sent via pgsql-general mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
