Commit 514c96d4 authored by Pierre DAVID's avatar Pierre DAVID

Fix DELETE triggers on host/alias/mx deletion

parent 83ac8ce9
......@@ -379,10 +379,13 @@ CREATE OR REPLACE FUNCTION dns.mod_mx_alias ()
PERFORM sum (dns.gen_norm_idname (OLD.idname)) ;
END IF ;
IF TG_OP = 'DELETE'
THEN
PERFORM sum (dns.gen_norm_idname (OLD.idname)) ;
END IF ;
-- There is no delete trigger on dns.mx nor dns.alias:
-- Forward zone is modified by dns.del_name explicitly
-- triggered for a delete on these tables
-- IF TG_OP = 'DELETE'
-- THEN
-- nothing
-- END IF ;
RETURN NEW ;
END ;
......@@ -470,10 +473,14 @@ CREATE OR REPLACE FUNCTION dns.mod_host ()
-- IP addresses did not change
END IF ;
-- There is no delete trigger on dns.host:
-- reverse zone is modified when triggering delete
-- on dns.addr
-- forward zone is modified when the dns.name row is deleted
-- (implicitly via a distinct delete trigger on dns.host)
-- IF TG_OP = 'DELETE'
-- THEN
-- no need to regenerate anything since all IP addresses have
-- already been removed before
-- nothing
-- END IF ;
RETURN NEW ;
......@@ -594,6 +601,11 @@ CREATE OR REPLACE FUNCTION dns.check_ip_grp (INET, INTEGER)
CREATE OR REPLACE FUNCTION dns.del_name ()
RETURNS trigger AS $$
BEGIN
PERFORM sum (dns.gen_norm_iddom (n.iddom, n.idview))
FROM dns.name n
WHERE n.idname = OLD.idname
;
BEGIN
DELETE FROM dns.name WHERE idname = OLD.idname ;
RETURN NULL ;
......@@ -603,6 +615,7 @@ CREATE OR REPLACE FUNCTION dns.del_name ()
-- do nothing
RETURN NULL ;
END ;
END ;
$$ LANGUAGE 'plpgsql' ;
------------------------------------------------------------------------------
......
......@@ -36,15 +36,15 @@ CREATE TRIGGER tr_mod_addr
FOR EACH ROW EXECUTE PROCEDURE dns.mod_addr () ;
CREATE TRIGGER tr_mod_host
AFTER INSERT OR UPDATE OR DELETE ON dns.host
AFTER INSERT OR UPDATE ON dns.host
FOR EACH ROW EXECUTE PROCEDURE dns.mod_host () ;
CREATE TRIGGER tr_mod_alias
AFTER INSERT OR UPDATE OR DELETE ON dns.alias
AFTER INSERT OR UPDATE ON dns.alias
FOR EACH ROW EXECUTE PROCEDURE dns.mod_mx_alias () ;
CREATE TRIGGER tr_mod_mx
AFTER INSERT OR UPDATE OR DELETE ON dns.mx
AFTER INSERT OR UPDATE ON dns.mx
FOR EACH ROW EXECUTE PROCEDURE dns.mod_mx_alias () ;
CREATE TRIGGER tr_mod_name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment