Use INSERT.. ON DUPLICATE... instead of REPLACE INTO. REPLACE INTO deletes the existing row. Since we now have event counts in there, we lose them.
This commit is contained in:
parent
b3e3fea79f
commit
cda3824a25
|
@ -244,7 +244,7 @@ int main(int argc, char *argv[]) {
|
|||
monitors[i]->setStartupTime(now);
|
||||
|
||||
snprintf(sql, sizeof(sql),
|
||||
"REPLACE INTO Monitor_Status (MonitorId, Status) VALUES ('%d','Running')",
|
||||
"INSERT INTO Monitor_Status (MonitorId,Status) VALUES (%d, 'Running') ON DUPLICATE KEY UPDATE Status='Running'",
|
||||
monitors[i]->Id());
|
||||
if ( mysql_query(&dbconn, sql) ) {
|
||||
Error("Can't run query: %s", mysql_error(&dbconn));
|
||||
|
@ -273,7 +273,7 @@ int main(int argc, char *argv[]) {
|
|||
capture_delays[i] = monitors[i]->GetCaptureDelay();
|
||||
alarm_capture_delays[i] = monitors[i]->GetAlarmCaptureDelay();
|
||||
snprintf(sql, sizeof(sql),
|
||||
"REPLACE INTO Monitor_Status (MonitorId, Status) VALUES ('%d','Connected')",
|
||||
"INSERT INTO Monitor_Status (MonitorId,Status) VALUES (%d, 'Connected') ON DUPLICATE KEY UPDATE Status='Connected'",
|
||||
monitors[i]->Id());
|
||||
if ( mysql_query(&dbconn, sql) ) {
|
||||
Error("Can't run query: %s", mysql_error(&dbconn));
|
||||
|
@ -364,7 +364,7 @@ int main(int argc, char *argv[]) {
|
|||
for ( int i = 0; i < n_monitors; i++ ) {
|
||||
static char sql[ZM_SQL_SML_BUFSIZ];
|
||||
snprintf(sql, sizeof(sql),
|
||||
"REPLACE INTO Monitor_Status (MonitorId, Status) VALUES ('%d','NotRunning')",
|
||||
"INSERT INTO Monitor_Status (MonitorId,Status) VALUES (%d, 'Connected') ON DUPLICATE KEY UPDATE Status='NotRunning'",
|
||||
monitors[i]->Id());
|
||||
if ( mysql_query(&dbconn, sql) ) {
|
||||
Error("Can't run query: %s", mysql_error(&dbconn));
|
||||
|
|
Loading…
Reference in New Issue