File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -83,17 +83,21 @@ CREATE PROCEDURE ReplaceCloudRecord(
83
83
BEGIN
84
84
DECLARE measurementTimeCalculated DATETIME;
85
85
DECLARE recordCreateTimeNotNull DATETIME;
86
+ DECLARE endTimeNotNull DATETIME;
86
87
87
88
IF(status= ' completed' ) THEN
88
89
-- in this case, the recordCreateTime and measurementTime could
89
90
-- be wildly different as the VM has ended.
90
91
91
92
-- if we werent supplied a record create time
92
93
-- for a completed VM we have decided to use the end time
93
- SET recordCreateTimeNotNull = IF(recordCreateTime IS NULL or recordCreateTime= ' 0000-00-00 00:00:00' , endTime, recordCreateTime);
94
+ -- We have to check the EndTime is not null because we can't guarantee this as we
95
+ -- previously loaded completed messages with no EndTime.
96
+ SET endTimeNotNull = IFNULL(endTime, ' 0000-00-00 00:00:00' );
97
+ SET recordCreateTimeNotNull = IF(recordCreateTime IS NULL or recordCreateTime= ' 0000-00-00 00:00:00' , endTimeNotNull, recordCreateTime);
94
98
95
99
-- Use the end time as the measurement time
96
- SET measurementTimeCalculated = endTime ;
100
+ SET measurementTimeCalculated = endTimeNotNull ;
97
101
98
102
ELSE
99
103
-- In the case of a running VM, the measurement time will
Original file line number Diff line number Diff line change @@ -33,17 +33,21 @@ CREATE PROCEDURE ReplaceCloudRecord(
33
33
BEGIN
34
34
DECLARE measurementTimeCalculated DATETIME;
35
35
DECLARE recordCreateTimeNotNull DATETIME;
36
+ DECLARE endTimeNotNull DATETIME;
36
37
37
38
IF(status= ' completed' ) THEN
38
39
-- in this case, the recordCreateTime and measurementTime could
39
40
-- be wildly different as the VM has ended.
40
41
41
42
-- if we werent supplied a record create time
42
43
-- for a completed VM we have decided to use the end time
43
- SET recordCreateTimeNotNull = IF(recordCreateTime IS NULL or recordCreateTime= ' 0000-00-00 00:00:00' , endTime, recordCreateTime);
44
+ -- We have to check the EndTime is not null because we can't guarantee this as we
45
+ -- previously loaded completed messages with no EndTime.
46
+ SET endTimeNotNull = IFNULL(endTime, ' 0000-00-00 00:00:00' );
47
+ SET recordCreateTimeNotNull = IF(recordCreateTime IS NULL or recordCreateTime= ' 0000-00-00 00:00:00' , endTimeNotNull, recordCreateTime);
44
48
45
49
-- Use the end time as the measurement time
46
- SET measurementTimeCalculated = endTime ;
50
+ SET measurementTimeCalculated = endTimeNotNull ;
47
51
48
52
ELSE
49
53
-- In the case of a running VM, the measurement time will
You can’t perform that action at this time.
0 commit comments