summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-23 13:18:44 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-23 13:18:44 +0000
commit90c8eec0c0e5e610b7ba83c1ba46e598f0d060e2 (patch)
treeb430fed67c7a6c8ceb644cf572ad306ffa70b7b7 /src
parent28ea498fb942dde92b001d20d3936b749a43c117 (diff)
downloadzabbix-90c8eec0c0e5e610b7ba83c1ba46e598f0d060e2.tar.gz
zabbix-90c8eec0c0e5e610b7ba83c1ba46e598f0d060e2.tar.xz
zabbix-90c8eec0c0e5e610b7ba83c1ba46e598f0d060e2.zip
- eliminated function DBaffected_rows() (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@2883 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
-rw-r--r--src/libs/zbxdbhigh/db.c47
-rw-r--r--src/zabbix_server/housekeeper/housekeeper.c13
2 files changed, 20 insertions, 40 deletions
diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c
index 26dccda4..a8f9e8cc 100644
--- a/src/libs/zbxdbhigh/db.c
+++ b/src/libs/zbxdbhigh/db.c
@@ -1,4 +1,4 @@
-/*
+/*
** ZABBIX
** Copyright (C) 2000-2005 SIA Zabbix
**
@@ -109,7 +109,7 @@ void DBconnect(void)
exit(FAIL);
}
/* login */
- snprintf(connect,MAX_STRING_LEN-1,"%s/%s/@%s", CONFIG_DBUSER, CONFIG_DBPASSWORD, CONFIG_DBNAME);
+ snprintf(connect,MAX_STRING_LEN-1,"%s/%s@%s", CONFIG_DBUSER, CONFIG_DBPASSWORD, CONFIG_DBNAME);
if (SQLO_SUCCESS != sqlo_connect(&oracle, connect))
{
printf("Cannot login with %s\n", connect);
@@ -131,26 +131,18 @@ int DBexecute(char *query)
/* if(strstr(query, "17828") != NULL)*/
zabbix_log( LOG_LEVEL_DEBUG, "Executing query:%s",query);
- while( mysql_query(&mysql,query) != 0)
+ if(mysql_query(&mysql,query) != 0)
{
zabbix_log( LOG_LEVEL_ERR, "Query::%s",query);
zabbix_log(LOG_LEVEL_ERR, "Query failed:%s [%d]", mysql_error(&mysql), mysql_errno(&mysql) );
-
- if( (ER_SERVER_SHUTDOWN != mysql_errno(&mysql)) &&
- (CR_SERVER_GONE_ERROR != mysql_errno(&mysql)) &&
- (CR_CONNECTION_ERROR != mysql_errno(&mysql)))
- {
- return FAIL;
- }
-
- DBclose();
- DBconnect();
+ return FAIL;
}
+ return (long)mysql_affected_rows(&mysql);
#endif
#ifdef HAVE_PGSQL
PGresult *result;
- zabbix_log( LOG_LEVEL_DEBUG, "Executing query:%s",query);
+ aabbix_log( LOG_LEVEL_DEBUG, "Executing query:%s",query);
result = PQexec(conn,query);
if( result==NULL)
@@ -170,18 +162,18 @@ int DBexecute(char *query)
PQclear(result);
#endif
#ifdef HAVE_ORACLE
+ int ret;
zabbix_log( LOG_LEVEL_DEBUG, "Executing query:%s",query);
- if ( sqlo_exec(oracle, query)<0 )
+ if ( (ret = sqlo_exec(oracle, query))<0 )
{
zabbix_log( LOG_LEVEL_ERR, "Query::%s",query);
zabbix_log(LOG_LEVEL_ERR, "Query failed:%s", sqlo_geterror(oracle) );
fprintf(stderr, "Query::%s\n",query);
fprintf(stderr, "Query failed:%s\n", sqlo_geterror(oracle) );
- return FAIL;
+ ret = FAIL;
}
+ return ret;
#endif
-/* zabbix_set_log_level(LOG_LEVEL_WARNING);*/
- return SUCCEED;
}
int DBis_null(char *field)
@@ -231,22 +223,13 @@ DB_RESULT DBselect(char *query)
#ifdef HAVE_MYSQL
zabbix_log( LOG_LEVEL_DEBUG, "Executing query:%s",query);
- while(mysql_query(&mysql,query) != 0)
+ if(mysql_query(&mysql,query) != 0)
{
zabbix_log( LOG_LEVEL_ERR, "Query::%s",query);
zabbix_log(LOG_LEVEL_ERR, "Query failed:%s [%d]", mysql_error(&mysql), mysql_errno(&mysql) );
- if( (ER_SERVER_SHUTDOWN != mysql_errno(&mysql)) &&
- (CR_SERVER_GONE_ERROR != mysql_errno(&mysql)) &&
- (CR_CONNECTION_ERROR != mysql_errno(&mysql)))
- {
- exit(FAIL);
- }
-
- DBclose();
- DBconnect();
+ exit(FAIL);
}
-
return mysql_store_result(&mysql);
#endif
#ifdef HAVE_PGSQL
@@ -352,10 +335,10 @@ int DBinsert_id()
/*
* Returs number of affected rows of last select, update, delete or replace
*/
+/*
long DBaffected_rows()
{
#ifdef HAVE_MYSQL
- /* It actually returns my_ulonglong */
return (long)mysql_affected_rows(&mysql);
#endif
#ifdef HAVE_PGSQL
@@ -364,7 +347,7 @@ long DBaffected_rows()
#ifdef HAVE_ORACLE
return FAIL;
#endif
-}
+}*/
/*
@@ -897,6 +880,7 @@ void DBdelete_sysmaps_hosts_by_hostid(int hostid)
DBexecute(sql);
}
+/*
int DBdelete_history_pertial(int itemid)
{
char sql[MAX_STRING_LEN];
@@ -910,6 +894,7 @@ int DBdelete_history_pertial(int itemid)
return DBaffected_rows();
}
+*/
void DBupdate_triggers_status_after_restart(void)
{
diff --git a/src/zabbix_server/housekeeper/housekeeper.c b/src/zabbix_server/housekeeper/housekeeper.c
index 4f86eadc..88147187 100644
--- a/src/zabbix_server/housekeeper/housekeeper.c
+++ b/src/zabbix_server/housekeeper/housekeeper.c
@@ -95,9 +95,7 @@ static int housekeeping_process_log()
#else
snprintf(sql,sizeof(sql)-1,"delete from %s where %s=%d limit 500",housekeeper.tablename, housekeeper.field,housekeeper.value);
#endif
- DBexecute(sql);
-
- if(( deleted = DBaffected_rows()) == 0)
+ if(( deleted = DBexecute(sql)) == 0)
{
snprintf(sql,sizeof(sql)-1,"delete from housekeeper where housekeeperid=%d",housekeeper.housekeeperid);
DBexecute(sql);
@@ -120,9 +118,8 @@ static int housekeeping_sessions(int now)
zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_sessions(%d)", now);
snprintf(sql,sizeof(sql)-1,"delete from sessions where lastaccess<%d",now-24*3600);
- DBexecute(sql);
- zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [sessions]", DBaffected_rows());
+ zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [sessions]", DBexecute(sql));
return SUCCEED;
}
@@ -152,8 +149,7 @@ static int housekeeping_alerts(int now)
alert_history=atoi(row[0]);
snprintf(sql,sizeof(sql)-1,"delete from alerts where clock<%d",now-24*3600*alert_history);
- DBexecute(sql);
- zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [alerts]", DBaffected_rows());
+ zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [alerts]", DBexecute(sql));
}
DBfree_result(result);
@@ -196,11 +192,10 @@ static int housekeeping_alarms(int now)
DBexecute(sql);
snprintf(sql,sizeof(sql)-1,"delete from alarms where alarmid=%d",alarmid);
- DBexecute(sql);
+ zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [alarms]", DBexecute(sql));
}
DBfree_result(result2);
- zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [alarms]", DBaffected_rows());
}
DBfree_result(result);