From 409a385590a070d95170b2f26dff3dc16f3fe691 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Mon, 20 Jun 2016 17:38:01 +0200 Subject: [PATCH] DB IDO: Ensure that delete queries for comments/downtimes are matching the index fixes #11993 --- lib/db_ido/dbevents.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index b19bfad5d..709cc8a3c 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -403,19 +403,21 @@ void DbEvents::RemoveCommentInternal(std::vector& queries, const Commen { Checkable::Ptr checkable = comment->GetCheckable(); + unsigned long entry_time = static_cast(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(comment->GetEntryTime()); - double now = Utility::GetTime(); std::pair time_bag = CompatUtility::ConvertTimestamp(now); @@ -582,6 +584,7 @@ void DbEvents::RemoveDowntimeInternal(std::vector& 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);