Sure, you can use EVENT TRIGGERS and you can create them on any of these DDL events listed here

CREATE OR REPLACE FUNCTION abort_any_command() RETURNS event_trigger LANGUAGE plpgsql AS $$ BEGIN RAISE EXCEPTION '[%] user % attempt command % which disabled', current_timestamp, current_user, tg_tag; END; $$; CREATE EVENT TRIGGER abort_ddl ON ddl_command_start WHEN TAG IN ('DROP FUNCTION', 'CREATE FUNCTION') EXECUTE PROCEDURE abort_any_command();

You can create the EVENT TRIGGER on ddl_command_end if you want an event to trigger ONLY after the operation has completed successfully. After you create an EVENT TRIGGER , you can try to drop the function and you'll see.

DROP FUNCTION abort_any_command(); ERROR: [2017-01-09 20:27:33.843529-06] user ecarroll attempt command DROP FUNCTION which disabled