From 1632415370643c4279b6adc4ce1e144b20b86059 Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Thu, 10 Aug 2017 16:42:02 +0200 Subject: [PATCH] Fix commenthistory refs #5492 --- lib/db_ido/dbevents.cpp | 4 ++-- lib/db_ido_mysql/schema/mysql.sql | 7 +++++-- lib/db_ido_mysql/schema/upgrade/2.8.0.sql | 7 +++++++ lib/db_ido_pgsql/schema/pgsql.sql | 4 ++++ lib/db_ido_pgsql/schema/upgrade/2.8.0.sql | 6 ++++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index 557a0e65d..315bd5384 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -409,7 +409,7 @@ void DbEvents::RemoveCommentInternal(std::vector& queries, const Commen query1.Category = DbCatComment; query1.WhereCriteria = new Dictionary(); query1.WhereCriteria->Set("object_id", checkable); - query1.WhereCriteria->Set("comment_time", DbValue::FromTimestamp(entry_time)); + query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time)); query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ query1.WhereCriteria->Set("name", comment->GetName()); queries.push_back(query1); @@ -430,7 +430,7 @@ void DbEvents::RemoveCommentInternal(std::vector& queries, const Commen query2.WhereCriteria = new Dictionary(); query2.WhereCriteria->Set("object_id", checkable); - query2.WhereCriteria->Set("comment_time", DbValue::FromTimestamp(entry_time)); + query2.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time)); query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ query2.WhereCriteria->Set("name", comment->GetName()); queries.push_back(query2); diff --git a/lib/db_ido_mysql/schema/mysql.sql b/lib/db_ido_mysql/schema/mysql.sql index 8f7238a97..2acff559a 100644 --- a/lib/db_ido_mysql/schema/mysql.sql +++ b/lib/db_ido_mysql/schema/mysql.sql @@ -1682,9 +1682,12 @@ CREATE INDEX idx_service_contacts_service_id on icinga_service_contacts(service_ CREATE INDEX idx_host_contacts_host_id on icinga_host_contacts(host_id); -- #5458 -CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); -CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); +create index idx_downtimehistory_remove on icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); +create index idx_scheduleddowntime_remove on icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); +-- #5492 +CREATE INDEX idx_commenthistory_remove ON icinga_commenthistory (object_id, entry_time); +CREATE INDEX idx_comments_remove ON icinga_comments (object_id, entry_time); -- ----------------------------------------- -- set dbversion diff --git a/lib/db_ido_mysql/schema/upgrade/2.8.0.sql b/lib/db_ido_mysql/schema/upgrade/2.8.0.sql index 5e0facf9f..5fed98312 100644 --- a/lib/db_ido_mysql/schema/upgrade/2.8.0.sql +++ b/lib/db_ido_mysql/schema/upgrade/2.8.0.sql @@ -16,6 +16,13 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); +-- ----------------------------------------- +-- #5492 IDO: Improve comment removal +-- ----------------------------------------- + +CREATE INDEX idx_commenthistory_remove ON icinga_commenthistory (object_id, entry_time); +CREATE INDEX idx_comments_remove ON icinga_comments (object_id, entry_time); + -- ----------------------------------------- -- set dbversion -- ----------------------------------------- diff --git a/lib/db_ido_pgsql/schema/pgsql.sql b/lib/db_ido_pgsql/schema/pgsql.sql index bbd54b4be..fb033d2b7 100644 --- a/lib/db_ido_pgsql/schema/pgsql.sql +++ b/lib/db_ido_pgsql/schema/pgsql.sql @@ -1725,6 +1725,10 @@ CREATE INDEX idx_host_contacts_host_id on icinga_host_contacts(host_id); CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); +-- #5492 +CREATE INDEX idx_commenthistory_remove ON icinga_commenthistory (object_id, entry_time); +CREATE INDEX idx_comments_remove ON icinga_comments (object_id, entry_time); + -- ----------------------------------------- -- set dbversion -- ----------------------------------------- diff --git a/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql b/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql index 620486748..8e49f17eb 100644 --- a/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql +++ b/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql @@ -14,6 +14,12 @@ CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); +-- ----------------------------------------- +-- #5492 +-- ----------------------------------------- + +CREATE INDEX idx_commenthistory_remove ON icinga_commenthistory (object_id, entry_time); +CREATE INDEX idx_comments_remove ON icinga_comments (object_id, entry_time); -- ----------------------------------------- -- set dbversion -- -----------------------------------------