summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libs/zbxdbhigh/db.c9
-rw-r--r--src/zabbix_server/nodewatcher/nodewatcher.c18
2 files changed, 15 insertions, 12 deletions
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index 4635fe82..7208aa05 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -265,7 +265,9 @@ int DBexecute(const char *fmt, ...)
if( PQresultStatus(result) != PGRES_COMMAND_OK)
{
zabbix_log( LOG_LEVEL_ERR, "Query::%s",sql);
- zabbix_log(LOG_LEVEL_ERR, "Query failed:%s", PQresStatus(PQresultStatus(result)) );
+ zabbix_log(LOG_LEVEL_ERR, "Query failed:%s:%s",
+ PQresStatus(PQresultStatus(result)),
+ PQresultErrorMessage(result));
PQclear(result);
return FAIL;
}
@@ -481,7 +483,9 @@ DB_RESULT DBselect(const char *fmt, ...)
if( PQresultStatus(result->pg_result) != PGRES_TUPLES_OK)
{
zabbix_log(LOG_LEVEL_ERR, "Query::%s",sql);
- zabbix_log(LOG_LEVEL_ERR, "Query failed:%s", PQresStatus(PQresultStatus(result->pg_result)) );
+ zabbix_log(LOG_LEVEL_ERR, "Query failed:%s:%s",
+ PQresStatus(PQresultStatus(result->pg_result)),
+ PQresultErrorMessage(result->pg_result));
exit( FAIL );
}
@@ -1814,7 +1818,6 @@ void DBvacuum(void)
"sessions", "rights", "service_alarms", "profiles", "screens", "screens_items",
NULL};
- char sql[MAX_STRING_LEN];
char *table;
int i;
diff --git a/src/zabbix_server/nodewatcher/nodewatcher.c b/src/zabbix_server/nodewatcher/nodewatcher.c
index 5653e316..de62267c 100644
--- a/src/zabbix_server/nodewatcher/nodewatcher.c
+++ b/src/zabbix_server/nodewatcher/nodewatcher.c
@@ -210,7 +210,7 @@ static int compare_checksums()
/* Begin work */
/* Find updated records */
- result = DBselect("select new.nodeid,new.tablename,new.recordid from node_cksum old, node_cksum new where new.tablename=old.tablename and new.recordid=old.recordid and new.fieldname=old.fieldname and new.nodeid=old.nodeid and new.cksum<>old.cksum and new.cksumtype=%d and old.cksumtype=%d", NODE_CKSUM_TYPE_NEW, NODE_CKSUM_TYPE_OLD);
+ result = DBselect("select curr.nodeid,curr.tablename,curr.recordid from node_cksum prev, node_cksum curr where curr.tablename=prev.tablename and curr.recordid=prev.recordid and curr.fieldname=prev.fieldname and curr.nodeid=prev.nodeid and curr.cksum<>prev.cksum and curr.cksumtype=%d and prev.cksumtype=%d", NODE_CKSUM_TYPE_NEW, NODE_CKSUM_TYPE_OLD);
while((row=DBfetch(result)))
{
// zabbix_log( LOG_LEVEL_WARNING, "Adding record to node_configlog");
@@ -222,10 +222,10 @@ static int compare_checksums()
DBfree_result(result);
/* Find new records */
- result = DBselect("select new.nodeid,new.tablename,new.recordid from node_cksum new" \
- " left join node_cksum old" \
- " on new.tablename=old.tablename and new.recordid=old.recordid and new.fieldname=old.fieldname and new.nodeid=old.nodeid and new.cksumtype<>old.cksumtype" \
- " where old.cksumid is null and new.cksumtype=%d", NODE_CKSUM_TYPE_NEW);
+ result = DBselect("select curr.nodeid,curr.tablename,curr.recordid from node_cksum curr" \
+ " left join node_cksum prev" \
+ " on curr.tablename=prev.tablename and curr.recordid=prev.recordid and curr.fieldname=prev.fieldname and curr.nodeid=prev.nodeid and curr.cksumtype<>prev.cksumtype" \
+ " where prev.cksumid is null and curr.cksumtype=%d", NODE_CKSUM_TYPE_NEW);
while((row=DBfetch(result)))
{
@@ -238,10 +238,10 @@ static int compare_checksums()
DBfree_result(result);
/* Find deleted records */
- result = DBselect("select new.nodeid,new.tablename,new.recordid from node_cksum new" \
- " left join node_cksum old" \
- " on new.tablename=old.tablename and new.recordid=old.recordid and new.fieldname=old.fieldname and new.nodeid=old.nodeid and new.cksumtype<>old.cksumtype" \
- " where old.cksumid is null and new.cksumtype=%d", NODE_CKSUM_TYPE_OLD);
+ result = DBselect("select curr.nodeid,curr.tablename,curr.recordid from node_cksum curr" \
+ " left join node_cksum prev" \
+ " on curr.tablename=prev.tablename and curr.recordid=prev.recordid and curr.fieldname=prev.fieldname and curr.nodeid=prev.nodeid and curr.cksumtype<>prev.cksumtype" \
+ " where prev.cksumid is null and curr.cksumtype=%d", NODE_CKSUM_TYPE_OLD);
while((row=DBfetch(result)))
{