Fix triggers that update Storage
This commit is contained in:
parent
691ff5881d
commit
2e7aa17882
|
@ -420,14 +420,14 @@ BEGIN
|
||||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||||
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
||||||
IF ( diff ) THEN
|
IF ( diff ) THEN
|
||||||
UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) + diff,0) WHERE Monitor_Status.MonitorId = OLD.StorageId;
|
UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) + diff,0) WHERE Storage.Id = OLD.StorageId;
|
||||||
END IF;
|
END IF;
|
||||||
ELSE
|
ELSE
|
||||||
IF ( NEW.DiskSpace ) THEN
|
IF ( NEW.DiskSpace ) THEN
|
||||||
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) + NEW.DiskSpace WHERE Monitor_Status.MonitorId = NEW.StorageId;
|
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) + NEW.DiskSpace WHERE Storage.Id = NEW.StorageId;
|
||||||
END IF;
|
END IF;
|
||||||
IF ( OLD.DiskSpace ) THEN
|
IF ( OLD.DiskSpace ) THEN
|
||||||
UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) - OLD.DiskSpace,0) WHERE Monitor_Status.MonitorId = OLD.StorageId;
|
UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) - OLD.DiskSpace,0) WHERE Storage.Id = OLD.StorageId;
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ CREATE TRIGGER event_delete_trigger BEFORE DELETE ON Events
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
IF ( OLD.DiskSpace ) THEN
|
IF ( OLD.DiskSpace ) THEN
|
||||||
UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) - COALESCE(OLD.DiskSpace,0),0) WHERE Monitor_Status.MonitorId = OLD.StorageId;
|
UPDATE Storage SET DiskSpace = GREATEST(COALESCE(DiskSpace,0) - COALESCE(OLD.DiskSpace,0),0) WHERE Storage.Id = OLD.StorageId;
|
||||||
END IF;
|
END IF;
|
||||||
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
|
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
|
||||||
DELETE FROM Events_Day WHERE EventId=OLD.Id;
|
DELETE FROM Events_Day WHERE EventId=OLD.Id;
|
||||||
|
|
Loading…
Reference in New Issue