From 2b643640a892dd039daa58e6d5ce3333e7381311 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Mon, 8 Feb 2016 11:05:27 +0100 Subject: [PATCH] DB IDO: Fix problem with hostgroup_members cleanup fixes #11103 --- lib/db_ido/hostdbobject.cpp | 9 ++++++--- lib/db_ido/servicedbobject.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index 053860bfb..a4c629ff7 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -189,15 +189,16 @@ void HostDbObject::OnConfigUpdate(void) BOOST_FOREACH(const String& groupName, groups) { HostGroup::Ptr group = HostGroup::GetByName(groupName); + std::vector queries; + DbQuery query1; query1.Table = DbType::GetByName("HostGroup")->GetTable() + "_members"; query1.Type = DbQueryDelete; query1.Category = DbCatConfig; query1.WhereCriteria = new Dictionary(); query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ - query1.WhereCriteria->Set("hostgroup_id", DbValue::FromObjectInsertID(group)); query1.WhereCriteria->Set("host_object_id", host); - OnQuery(query1); + queries.push_back(query1); DbQuery query2; query2.Table = DbType::GetByName("HostGroup")->GetTable() + "_members"; @@ -207,7 +208,9 @@ void HostDbObject::OnConfigUpdate(void) query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */ query2.Fields->Set("hostgroup_id", DbValue::FromObjectInsertID(group)); query2.Fields->Set("host_object_id", host); - OnQuery(query2); + queries.push_back(query2); + + DbObject::OnMultipleQueries(queries); } } diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index ef5f4e1b4..2f1e55bc3 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -188,15 +188,16 @@ void ServiceDbObject::OnConfigUpdate(void) BOOST_FOREACH(const String& groupName, groups) { ServiceGroup::Ptr group = ServiceGroup::GetByName(groupName); + std::vector queries; + DbQuery query1; query1.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members"; query1.Type = DbQueryDelete; query1.Category = DbCatConfig; query1.WhereCriteria = new Dictionary(); query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ - query1.WhereCriteria->Set("servicegroup_id", DbValue::FromObjectInsertID(group)); query1.WhereCriteria->Set("service_object_id", service); - OnQuery(query1); + queries.push_back(query1); DbQuery query2; query2.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members"; @@ -206,7 +207,9 @@ void ServiceDbObject::OnConfigUpdate(void) query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */ query2.Fields->Set("servicegroup_id", DbValue::FromObjectInsertID(group)); query2.Fields->Set("service_object_id", service); - OnQuery(query2); + queries.push_back(query2); + + DbObject::OnMultipleQueries(queries); } }