From ec62a02b34b7b2c9e3ad1055c120d9c0c467ea5c Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Sun, 5 Jul 2026 18:36:32 +0000 Subject: [PATCH] Remove sex rules regards actor/actee in mating events Change to a warning. There may be some same-sex mating events. We could make another event code for same-sex mating events, but why? --- .../lib/triggers/create/biography_data.m4 | 55 ----------------- db/schemas/lib/triggers/create/roles.m4 | 59 ------------------- doc/src/tables/events.m4 | 7 ++- 3 files changed, 5 insertions(+), 116 deletions(-) diff --git a/db/schemas/lib/triggers/create/biography_data.m4 b/db/schemas/lib/triggers/create/biography_data.m4 index 5490d7f..51dc747 100644 --- a/db/schemas/lib/triggers/create/biography_data.m4 +++ b/db/schemas/lib/triggers/create/biography_data.m4 @@ -830,61 +830,6 @@ CREATE OR REPLACE FUNCTION biography_data_func () || ')'; END IF; END IF; - - IF NEW.sex <> OLD.sex THEN - -- In mating events, the sdb_actor must be the male and the - -- sdb_actee the female. - SELECT roles.pid, roles.role - , events.eid, events.behavior, events.start - , watches.wid, watches.animid, watches.date, watches.type - INTO a_pid , a_role - , a_eid , a_behavior , a_start - , a_wid , a_animid , a_date , a_type - FROM roles - JOIN events ON (events.eid = roles.eid) - JOIN watches ON (watches.wid = events.wid) - WHERE roles.participant = NEW.animid - AND events.behavior = 'sdb_mating_event' - AND roles.participant = NEW.animid - AND ((roles.role = 'sdb_actor' - AND NEW.sex <> 'sdb_male') - OR (roles.role = 'sdb_actee' - AND NEW.sex <> 'sdb_female')) - -- Produce a consistent error message - ORDER BY watches.date, watches.wid - , roles.role, roles.pid - , events.start, events.eid; - IF FOUND THEN - RAISE EXCEPTION integrity_constraint_violation USING - MESSAGE = 'Error on UPDATE of BIOGRAPHY_DATA' - , DETAIL = 'Invalid Sex; in mating events, the ROLES.Role' - || ' of (sdb_actor) must be male and the' - || ' ROLES.Role of (sdb_actee) must be female' - || ': Key (AnimID) = (' - || NEW.animid - || '): Value (Sex) = (' - || NEW.Sex - || '): Key (ROLES.PID) = (' - || a_pid - || '), Value (ROLES.Role) = (' - || a_role - || '): Key (EVENTS.EID) = (' - || a_eid - || '): Value (EVENTS.Behavior) = (' - || a_behavior - || '), Value (EVENTS.Start) = (' - || a_start - || '): Key (WATCHES.WID) = (' - || a_wid - || '), Value (WATCHES.AnimID) = (' - || a_animid - || '), Value (WATCHES.Date) = (' - || a_date - || '), Value (WATCHES.Type) = (' - || a_type - || ')'; - END IF; - END IF; END; -- ARRIVALS diff --git a/db/schemas/lib/triggers/create/roles.m4 b/db/schemas/lib/triggers/create/roles.m4 index 51672e8..3f085bb 100644 --- a/db/schemas/lib/triggers/create/roles.m4 +++ b/db/schemas/lib/triggers/create/roles.m4 @@ -554,65 +554,6 @@ CREATE OR REPLACE FUNCTION roles_func () END; END IF; - -- - -- In mating events, the sdb_actor must be male and the sdb_actee - -- must be female. - -- - IF TG_OP = 'INSERT' - AND a_behavior = 'sdb_mating_event' THEN - DECLARE - target_sex biography_data.sex%TYPE; - a_sex biography_data.sex%TYPE; - - BEGIN - IF NEW.role = 'sdb_actor' THEN - target_sex := 'sdb_male'; - ELSE -- NEW.role = 'sdb_actee' - target_sex := 'sdb_female'; - END IF; - - SELECT biography_data.sex - INTO a_sex - WHERE biography_data.animid = NEW.participant - AND biography_data.sex <> target_sex; - - IF FOUND THEN - RAISE EXCEPTION integrity_constraint_violation USING - MESSAGE = 'Error on INSERT of ROLES' - , DETAIL = 'Invalid Participant value;' - || ' when the (Role) = (' - || NEW.role - || ' the sex of the participant must be (' - || target_sex - || ') but the sex is actually (' - || a_sex - || '): Inserting: Key (PID) = (' - || NEW.pid - || '), Value (EID) = (' - || NEW.eid - || '), Value (Role) = (' - || NEW.role - || '), Value (Participant) = (' - || NEW.participant - || '), Value (EVENTS.Behavior) = (' - || a_behavior - || '), Value (EVENTS.Start) = (' - || a_start - || '), Value (EVENTS.Stop) = (' - || a_stop - || '), Value (WATCHES.WID) = (' - || a_wid - || '), Value (WATCHES.AnimID) = (' - || a_animid - || '), Value (WATCHES.Date) = (' - || a_date - || '), Value (WATCHES.CommID) = (' - || a_commid - || ')'; - END IF; - END; - END IF; - RETURN NULL; END; $$; diff --git a/doc/src/tables/events.m4 b/doc/src/tables/events.m4 index 2ec951b..0742c0c 100644 --- a/doc/src/tables/events.m4 +++ b/doc/src/tables/events.m4 @@ -593,12 +593,15 @@ The following table lists these rules and implications: |ROLES|.\ |ROLES.Role| code values. The system will generate a warning when there are not exactly two |ROLES| rows related to a mating event. - The |ROLES|.\ |ROLES.Participant| must be male, must have a + The |ROLES|.\ |ROLES.Participant| should be male, must have a |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.Sex| value of ``sdb_male``, when the |ROLES|.\ |ROLES.Role| value is ``sdb_actor``. - The |ROLES|.\ |ROLES.Participant| must be female, must have a + The system will generate a warning when the male is not the actor. + The |ROLES|.\ |ROLES.Participant| should be female, must have a |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.Sex| value of ``sdb_male``, when the |ROLES|.\ |ROLES.Role| value is ``sdb_actee``. + The system will generate a warning when the female is not the + recipient. Both the EVENTS.\ |EVENTS.Start| and EVENTS.\ |EVENTS.Stop| columns record the time the mating was observed. -- 2.34.1