]> granicus.if.org Git - icinga2/commitdiff
DB IDO: Ensure that queries are not executed if categories don't match
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 2 Aug 2016 12:27:20 +0000 (14:27 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 2 Aug 2016 12:27:20 +0000 (14:27 +0200)
refs #12147
refs #12147

lib/db_ido_mysql/idomysqlconnection.cpp
lib/db_ido_pgsql/idopgsqlconnection.cpp

index 5efda95ab9a1c63fedd34e65b19263693d8fa1a7..c781d8f2819465eae7dafdb2d8c05a2485e70548 100644 (file)
@@ -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;
 
index b3f2e75d5aac5d675cf5bb30aed72a27d49bc913..71a970934a38e5b4a6e15e22246052b878ca8a1b 100644 (file)
@@ -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;