Home > Blockchain >  PostgreSQL drop function executes given function and doesn't remove trigger function
PostgreSQL drop function executes given function and doesn't remove trigger function

Time:05-03

I created the trigger function with the below code:

CREATE OR REPLACE FUNCTION snitch() RETURNS event_trigger AS $$
BEGIN
    select pgr_createTopology('public.roads_noded', 0.001);
END;
$$ LANGUAGE plpgsql;

CREATE EVENT TRIGGER snitch ON ddl_command_start EXECUTE FUNCTION snitch();

It is located in the public schema. Now I want to drop this function but when I try to drop it executes the given function and the server hangs. After restarting the server, the same thing happens. I can't create or drop any table. Is there a way to remove this trigger function?

CodePudding user response:

The DROP FUNCTION command is itself a DDL command so the trigger will fire. You should first remove the trigger using DROP EVENT TRIGGER, then the function.

  • Related