Clear ID cache when (re-)connecting.

Fixes #5108
This commit is contained in:
Gunnar Beutner 2013-11-20 09:32:30 +01:00
parent a4b2c2134d
commit 933ac5f403
4 changed files with 13 additions and 0 deletions

View File

@ -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<long>(m_LastNotificationID)));

View File

@ -139,6 +139,8 @@ void IdoPgsqlConnection::Reconnect(void)
}
}
ClearIDCache();
String ihost, iport, iuser, ipasswd, idb;
const char *host, *port, *user , *passwd, *db;

View File

@ -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)

View File

@ -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;