]> granicus.if.org Git - icinga2/commitdiff
DB IDO: Ensure that delete queries for comments/downtimes are matching the index
authorMichael Friedrich <michael.friedrich@netways.de>
Mon, 20 Jun 2016 15:38:01 +0000 (17:38 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Mon, 20 Jun 2016 15:38:01 +0000 (17:38 +0200)
fixes #11993

lib/db_ido/dbevents.cpp

index b19bfad5d37012fad2e3bff0d730ca630d1a4c6c..709cc8a3cbb9853984a44cf624a117a351262ee9 100644 (file)
@@ -403,19 +403,21 @@ void DbEvents::RemoveCommentInternal(std::vector<DbQuery>& queries, const Commen
 {
        Checkable::Ptr checkable = comment->GetCheckable();
 
+       unsigned long entry_time = static_cast<long>(comment->GetEntryTime());
+
        /* Status */
        DbQuery query1;
        query1.Table = "comments";
        query1.Type = DbQueryDelete;
        query1.Category = DbCatComment;
        query1.WhereCriteria = new Dictionary();
-       query1.WhereCriteria->Set("object_id", checkable);
        query1.WhereCriteria->Set("internal_comment_id", comment->GetLegacyId());
+       query1.WhereCriteria->Set("object_id", checkable);
+       query1.WhereCriteria->Set("comment_time", DbValue::FromTimestamp(entry_time));
+       query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
        queries.push_back(query1);
 
        /* History - update deletion time for service/host */
-       unsigned long entry_time = static_cast<long>(comment->GetEntryTime());
-
        double now = Utility::GetTime();
        std::pair<unsigned long, unsigned long> time_bag = CompatUtility::ConvertTimestamp(now);
 
@@ -582,6 +584,7 @@ void DbEvents::RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downt
        query1.WhereCriteria = new Dictionary();
        query1.WhereCriteria->Set("object_id", checkable);
        query1.WhereCriteria->Set("internal_downtime_id", downtime->GetLegacyId());
+       query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(downtime->GetEntryTime()));
        query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
        queries.push_back(query1);