diff --git a/components/db_ido_mysql/idomysqlconnection.cpp b/components/db_ido_mysql/idomysqlconnection.cpp index f1fe929d8..f42b9fa68 100644 --- a/components/db_ido_mysql/idomysqlconnection.cpp +++ b/components/db_ido_mysql/idomysqlconnection.cpp @@ -138,6 +138,8 @@ void IdoMysqlConnection::Reconnect(void) reconnect = true; } + ClearIDCache(); + String ihost, iuser, ipasswd, idb; const char *host, *user , *passwd, *db; long port; @@ -587,6 +589,7 @@ void IdoMysqlConnection::InternalExecuteQuery(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(LogDebug, "db_ido", "saving contactnotification notification_id=" + Convert::ToString(static_cast(m_LastNotificationID))); diff --git a/components/db_ido_pgsql/idopgsqlconnection.cpp b/components/db_ido_pgsql/idopgsqlconnection.cpp index 609275b1f..c731bffb7 100644 --- a/components/db_ido_pgsql/idopgsqlconnection.cpp +++ b/components/db_ido_pgsql/idopgsqlconnection.cpp @@ -139,6 +139,8 @@ void IdoPgsqlConnection::Reconnect(void) } } + ClearIDCache(); + String ihost, iport, iuser, ipasswd, idb; const char *host, *port, *user , *passwd, *db; diff --git a/lib/db_ido/dbconnection.cpp b/lib/db_ido/dbconnection.cpp index b20c6b27e..e325ea59f 100644 --- a/lib/db_ido/dbconnection.cpp +++ b/lib/db_ido/dbconnection.cpp @@ -201,6 +201,12 @@ DbReference DbConnection::GetInsertID(const DbObject::Ptr& dbobj) const return it->second; } +void DbConnection::ClearIDCache(void) +{ + m_ObjectIDs.clear(); + m_InsertIDs.clear(); +} + void DbConnection::SetConfigUpdate(const DbObject::Ptr& dbobj, bool hasupdate) { if (hasupdate) diff --git a/lib/db_ido/dbconnection.h b/lib/db_ido/dbconnection.h index b52b12f11..1e5decac5 100644 --- a/lib/db_ido/dbconnection.h +++ b/lib/db_ido/dbconnection.h @@ -47,6 +47,8 @@ public: void SetInsertID(const DbObject::Ptr& dbobj, const DbReference& dbref); DbReference GetInsertID(const DbObject::Ptr& dbobj) const; + void ClearIDCache(void); + void SetConfigUpdate(const DbObject::Ptr& dbobj, bool hasupdate); bool GetConfigUpdate(const DbObject::Ptr& dbobj) const;