]> granicus.if.org Git - icinga2/commitdiff
IdoMysqlConnection: Store last notifications insert id.
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 1 Oct 2013 10:45:09 +0000 (12:45 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 1 Oct 2013 10:45:09 +0000 (12:45 +0200)
refs #4768

components/db_ido_mysql/idomysqlconnection.cpp
components/db_ido_mysql/idomysqlconnection.h

index bfc7a123046629f8580be619fe21496526443b23..2fa8e9c3188d35f67c2a826d5e13ea4ab084157a 100644 (file)
@@ -339,6 +339,10 @@ bool IdoMysqlConnection::FieldToEscapedString(const String& key, const Value& va
                *result = static_cast<long>(m_InstanceID);
                return true;
        }
+       if (key == "notification_id") {
+               *result = static_cast<long>(m_LastNotificationID);
+               return true;
+       }
 
        Value rawvalue = DbValue::ExtractValue(value);
 
@@ -503,6 +507,10 @@ void IdoMysqlConnection::ExecuteQuery(const DbQuery& query)
                if (type == DbQueryInsert && query.ConfigUpdate)
                        SetInsertID(query.Object, GetLastInsertID());
        }
+       if (type == DbQueryInsert && query.Table == "notifications") { // FIXME remove hardcoded table name
+               m_LastNotificationID = GetLastInsertID();
+               Log(LogWarning, "db_ido", "saving contactnotification notification_id=" + Convert::ToString(static_cast<long>(m_LastNotificationID)));
+       }
 }
 
 void IdoMysqlConnection::CleanUpExecuteQuery(const String& table, const String& time_key, double time_value)
index 7c94ae260710a093926e0935eb169d85b6c3e91d..2eca680c6a5c538974183bf88074cd5adf5cd145 100644 (file)
@@ -63,6 +63,7 @@ private:
        String m_InstanceDescription;
 
        DbReference m_InstanceID;
+        DbReference m_LastNotificationID;
 
        boost::mutex m_ConnectionMutex;
        bool m_Connected;