[icinga-checkins] icinga.org: icinga2/master: DB IDO: Ensure that queries are not executed if categories don't match

git at icinga.org git at icinga.org
Tue Aug 2 14:28:10 CEST 2016


Module: icinga2
Branch: master
Commit: 53930e321c685de893e1ce1a17721d7e256e5577
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=53930e321c685de893e1ce1a17721d7e256e5577

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Tue Aug  2 14:27:20 2016 +0200

DB IDO: Ensure that queries are not executed if categories don't match

refs #12147
refs #12147

---

 lib/db_ido_mysql/idomysqlconnection.cpp |   12 +++++++-----
 lib/db_ido_pgsql/idopgsqlconnection.cpp |   12 +++++++-----
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp
index 5efda95..c781d8f 100644
--- a/lib/db_ido_mysql/idomysqlconnection.cpp
+++ b/lib/db_ido_mysql/idomysqlconnection.cpp
@@ -894,17 +894,19 @@ void IdoMysqlConnection::InternalExecuteQuery(const DbQuery& query, DbQueryType
 		return;
 	}
 
-	if (!CanExecuteQuery(query)) {
-		m_QueryQueue.Enqueue(boost::bind(&IdoMysqlConnection::InternalExecuteQuery, this, query, typeOverride), query.Priority);
-		return;
-	}
-
+	/* check whether we're allowed to execute the query first */
 	if (GetCategoryFilter() != DbCatEverything && (query.Category & GetCategoryFilter()) == 0)
 		return;
 
 	if (query.Object && query.Object->GetObject()->GetExtension("agent_check").ToBool())
 		return;
 
+	/* check if there are missing object/insert ids and re-enqueue the query */
+	if (!CanExecuteQuery(query)) {
+		m_QueryQueue.Enqueue(boost::bind(&IdoMysqlConnection::InternalExecuteQuery, this, query, typeOverride), query.Priority);
+		return;
+	}
+
 	std::ostringstream qbuf, where;
 	int type;
 
diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp
index b3f2e75..71a9709 100644
--- a/lib/db_ido_pgsql/idopgsqlconnection.cpp
+++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp
@@ -751,17 +751,19 @@ void IdoPgsqlConnection::InternalExecuteQuery(const DbQuery& query, DbQueryType
 		return;
 	}
 
-	if (!CanExecuteQuery(query)) {
-		m_QueryQueue.Enqueue(boost::bind(&IdoPgsqlConnection::InternalExecuteQuery, this, query, typeOverride), query.Priority);
-		return;
-	}
-
+	/* check whether we're allowed to execute the query first */
 	if (GetCategoryFilter() != DbCatEverything && (query.Category & GetCategoryFilter()) == 0)
 		return;
 
 	if (query.Object && query.Object->GetObject()->GetExtension("agent_check").ToBool())
 		return;
 
+	/* check if there are missing object/insert ids and re-enqueue the query */
+	if (!CanExecuteQuery(query)) {
+		m_QueryQueue.Enqueue(boost::bind(&IdoPgsqlConnection::InternalExecuteQuery, this, query, typeOverride), query.Priority);
+		return;
+	}
+
 	std::ostringstream qbuf, where;
 	int type;
 



More information about the icinga-checkins mailing list