From 465fc467df0f605980a53e0de080e690806cab46 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Mon, 1 Jun 2026 19:01:22 +0000 Subject: [PATCH] Use macro to enforce Start = Stop --- db/schemas/sokwedb/tables/create/events.m4 | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/db/schemas/sokwedb/tables/create/events.m4 b/db/schemas/sokwedb/tables/create/events.m4 index 78ef425..b11df97 100644 --- a/db/schemas/sokwedb/tables/create/events.m4 +++ b/db/schemas/sokwedb/tables/create/events.m4 @@ -23,6 +23,23 @@ include(`tablemacros.m4')dnl include(`grants.m4')dnl dnl +dnl Macro to ensure particular behavior codes enforce Start = Stop +dnl +dnl Syntax: _point_behavior_time(behavior) +dnl +dnl Input: +dnl behavior An EVENTS.Behavior value +dnl +dnl Remarks: +dnl Convenient macro that might not need to exist. +changequote([,]) +define([_point_behavior_time], [CONSTRAINT + "When the Behavior is ($1) Start must equal Stop" + CHECK(behavior <> '$1' + OR start = stop)])dnl +changequote(`,')dnl See above + + CREATE TABLE events ( key_column(`EVENTS', `EID', INTEGER) ,fid INTEGER @@ -54,13 +71,10 @@ CREATE TABLE events ( CONSTRAINT "Start cannot be after Stop" CHECK (start <= stop) - CONSTRAINT "When the Behavior is (sdb_aggression) Start must equal Stop" - CHECK (behavior <> 'sdb_aggression' - OR start = stop) - CONSTRAINT "When the Behavior is (sdb_groom_scan) Start must equal Stop" - CHECK (behavior <> 'sdb_groom_scan' - OR start = stop) null_xor_null(`FID', `AtID') + + _point_behavior_time(`sdb_aggression') + _point_behavior_time(`sdb_groom_scan') ); grant_priv(`EVENTS') -- 2.34.1