I have 2 tables, connected with inheritance.
I want to delete some rows from the child table. The deletion part works but it deletes rows from the parent as well:
CREATE OR REPLACE FUNCTION earthquakes_trigger()
RETURNS TRIGGER AS $$
BEGIN
INSERT INTO earthquakes VALUES (NEW.*);
DELETE FROM ONLY earthquakes WHERE datetime < (now() - '2 days'::interval);
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
CREATE TRIGGER earthquakes_trigger
BEFORE INSERT ON earthquakes_ovr
FOR EACH ROW EXECUTE PROCEDURE earthquakes_trigger();
Parent table : earthquakes_ovr
Child table: earthquakes
I also tried to break up the trigger function, and have the deletion part as trigger function on the child, but that didn't work either.