records from dci_access table deleted on template or derived object deletion
authorVictor Kirhenshtein <victor@netxms.org>
Sun, 12 Nov 2017 18:52:57 +0000 (20:52 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Sun, 12 Nov 2017 18:52:57 +0000 (20:52 +0200)
src/server/core/dcobject.cpp
src/server/core/template.cpp

index edf31c5..3f66992 100644 (file)
@@ -863,6 +863,9 @@ void DCObject::deleteFromDatabase()
        TCHAR query[256];
    _sntprintf(query, sizeof(query) / sizeof(TCHAR), _T("DELETE FROM dci_schedules WHERE item_id=%d"), (int)m_id);
    QueueSQLRequest(query);
+
+   _sntprintf(query, sizeof(query) / sizeof(TCHAR), _T("DELETE FROM dci_access WHERE dci_id=%d"), (int)m_id);
+   QueueSQLRequest(query);
 }
 
 /**
index 68d7ea3..85dfc23 100644 (file)
@@ -437,6 +437,11 @@ bool Template::deleteFromDatabase(DB_HANDLE hdb)
       {
          _sntprintf(query, 8192, _T("DELETE FROM dci_schedules WHERE item_id IN (%s)"), (const TCHAR *)listAll);
          success = DBQuery(hdb, query);
+         if (success)
+         {
+            _sntprintf(query, 8192, _T("DELETE FROM dci_access WHERE dci_id IN (%s)"), (const TCHAR *)listAll);
+            success = DBQuery(hdb, query);
+         }
       }
    }