[icinga-checkins] icinga.org: icinga-core/master: Host DB inserts use string 'NULL\n' instead of NULL (William Preston)

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


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

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

Host DB inserts use string 'NULL\n' instead of NULL (William Preston)

The initial inserts of host entries into the objects
table use the string 'NULL' instead of actual null values.

fixes #363

---

 AUTHORS                          |    1 +
 Changelog                        |    3 ++-
 module/idoutils/src/dbhandlers.c |   17 ++++++++++++++---
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 57aecb6..bcbf1bf 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -19,3 +19,4 @@ Sean Millichamp
 Tobias Scherbaum
 Ton Voon
 Vitali Voroth
+William Preston
diff --git a/Changelog b/Changelog
index 8ed9b88..3fb5954 100644
--- a/Changelog
+++ b/Changelog
@@ -7,10 +7,11 @@ Icinga 1.0.x Change Log
 ENHANCEMENTS
 * idoutils: Spread the list of linked lists thinner (extend objects hash slots) (Opsera Ltd)
 
-
 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)
+
 1.0.1 - 03/03/2010
 
 ENHANCEMENTS
diff --git a/module/idoutils/src/dbhandlers.c b/module/idoutils/src/dbhandlers.c
index 6bd18d1..248abcf 100644
--- a/module/idoutils/src/dbhandlers.c
+++ b/module/idoutils/src/dbhandlers.c
@@ -401,17 +401,28 @@ int ndo2db_get_object_id_with_insert(ndo2db_idi *idi, int object_type, char *n1,
 		return NDO_OK;
 
 	if (name1 != NULL) {
-		es[0] = ndo2db_db_escape_string(idi, name1);
+		tmp = ndo2db_db_escape_string(idi, name1);
+		asprintf(&es[0], "'%s'", tmp);
+		if (tmp) {
+			free(tmp);
+			tmp = NULL;
+		}
 	} else
 		asprintf(&es[0],"NULL");
+
 	if (name2 != NULL) {
-		es[1] = ndo2db_db_escape_string(idi, name2);
+		tmp = ndo2db_db_escape_string(idi, name2);
+		asprintf(&es[1], "'%s'", tmp);
+		if (tmp) {
+			free(tmp);
+			tmp = NULL;
+		}
 	} else
 		asprintf(&es[1], "NULL");
 
 #ifndef USE_ORACLE /* everything else will be libdbi */
 	if (asprintf(&buf,
-			"INSERT INTO %s (instance_id, objecttype_id, name1, name2) VALUES (%lu, %d, '%s', '%s')",
+			"INSERT INTO %s (instance_id, objecttype_id, name1, name2) VALUES (%lu, %d, %s, %s)",
 			ndo2db_db_tablenames[NDO2DB_DBTABLE_OBJECTS],
 			idi->dbinfo.instance_id, object_type, es[0],
 			es[1]) == -1)





More information about the icinga-checkins mailing list