From cb35a6dd90e810c747b4a863907b04a832242e72 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 9 Jul 2024 08:12:52 -0400 Subject: [PATCH] Handle case when OLD.DiskSpace is NULL --- db/triggers.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/triggers.sql b/db/triggers.sql index 58f09bcbf..37e11bbc5 100644 --- a/db/triggers.sql +++ b/db/triggers.sql @@ -133,7 +133,7 @@ BEGIN UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) + NEW.DiskSpace WHERE Storage.Id = NEW.StorageId; END IF; IF ( OLD.DiskSpace ) THEN - UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) - OLD.DiskSpace,0) WHERE Storage.Id = OLD.StorageId; + UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) - COALESCE(OLD.DiskSpace,0),0) WHERE Storage.Id = OLD.StorageId; END IF; END IF; @@ -172,7 +172,6 @@ BEGIN TotalEventDiskSpace = GREATEST(COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0),0) WHERE Event_Summaries.MonitorId=OLD.MonitorId; END IF; - END; //