CREATE OR REPLACE FUNCTION ddl_command_test()
RETURNS event_trigger
AS $$
DECLARE
obj record;
BEGIN
FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands()
LOOP
RAISE NOTICE '% commnad on oid: %',
tg_tag,
obj.objid;
RAISE NOTICE 'triggered';
END LOOP;
END; $$ LANGUAGE plpgsql;
CREATE EVENT TRIGGER test_ddl ON ddl_command_end
EXECUTE FUNCTION ddl_command_test();
While pg_event_trigger_ddl_commands() function returns info for table creation:
CREATE TABLE test_table(
col int
);
It not prints notification message when table is dropped:
DROP TABLE test_table;
Don't get why, because event-trigger-matrix shows that ddl_command_end includes DROP TABLE command also.