[icinga-checkins] icinga.org: icinga-core/master: ndo2db_get_object_id fails to return existing IDs (William Preston)

git at icinga.org git at icinga.org
Tue Apr 20 14:39:29 CEST 2010


Module: icinga-core
Branch: master
Commit: 201b683c0fe0a703057c9683c45100df83d4f111
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=201b683c0fe0a703057c9683c45100df83d4f111

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Tue Apr 20 14:32:46 2010 +0200

ndo2db_get_object_id fails to return existing IDs (William Preston)

fixes #364

---

 Changelog                        |    1 +
 module/idoutils/src/dbhandlers.c |   16 ++++++++--------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/Changelog b/Changelog
index 3fb5954..1dd414a 100644
--- a/Changelog
+++ b/Changelog
@@ -11,6 +11,7 @@ FIXES
 * core: fix spurious dollar signs added to command_lines (Alexander Wirt)
 
 * idoutils: Host DB inserts use string 'NULL\n' instead of NULL (William Preston)
+* idoutils: ndo2db_get_object_id fails to return existing IDs (William Preston)
 
 1.0.1 - 03/03/2010
 
diff --git a/module/idoutils/src/dbhandlers.c b/module/idoutils/src/dbhandlers.c
index 248abcf..03cd69c 100644
--- a/module/idoutils/src/dbhandlers.c
+++ b/module/idoutils/src/dbhandlers.c
@@ -162,16 +162,18 @@ int ndo2db_get_object_id(ndo2db_idi *idi, int object_type, char *n1, char *n2, u
                 }
 	}
 
-	if (asprintf(&buf, "SELECT * FROM %s WHERE instance_id='%lu' AND objecttype_id='%d' AND %s AND %s", ndo2db_db_tablenames[NDO2DB_DBTABLE_OBJECTS], idi->dbinfo.instance_id, object_type, buf1, buf2) == -1)
+	if (asprintf(&buf, "SELECT * FROM %s WHERE instance_id=%lu AND objecttype_id=%d AND %s AND %s", ndo2db_db_tablenames[NDO2DB_DBTABLE_OBJECTS], idi->dbinfo.instance_id, object_type, buf1, buf2) == -1)
 		buf = NULL;
 
 	if ((result = ndo2db_db_query(idi, buf)) == NDO_OK) {
 		if (idi->dbinfo.dbi_result != NULL) {
-			if (dbi_result_next_row(idi->dbinfo.dbi_result))
+			if (dbi_result_next_row(idi->dbinfo.dbi_result)) {
 				*object_id = dbi_result_get_ulong(idi->dbinfo.dbi_result, "object_id");
-				
+			} else {
+				result = NDO_ERROR;
+			}	
 
-				dbi_result_free(idi->dbinfo.dbi_result);
+			dbi_result_free(idi->dbinfo.dbi_result);
 			idi->dbinfo.dbi_result = NULL;
 		}
 	}
@@ -355,13 +357,11 @@ int ndo2db_get_object_id(ndo2db_idi *idi, int object_type, char *n1, char *n2, u
 #endif /* Oracle ocilib specific */
 
 	/* free memory */
-	ndo2db_log_debug_info(NDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_query_objects_select_() before free\n");
+	//ndo2db_log_debug_info(NDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_query_objects_select_() before free\n");
 	for (x = 0; x < NAGIOS_SIZEOF_ARRAY(es); x++)
 		free(es[x]);
 
-        ndo2db_log_debug_info(NDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_query_objects_select_() free of es\n");
-	if (found_object == NDO_FALSE)
-		result = NDO_ERROR;
+        //ndo2db_log_debug_info(NDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_query_objects_select_() free of es\n");
 
         ndo2db_log_debug_info(NDO2DB_DEBUGL_PROCESSINFO, 2, "ndo2db_get_object_id(%lu) end\n", *object_id);
 





More information about the icinga-checkins mailing list