[icinga-checkins] icinga.org: icinga-core/master: change select * into select [*_] id if unused results

git at icinga.org git at icinga.org
Tue Apr 20 16:17:23 CEST 2010


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

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Tue Apr 20 15:09:12 2010 +0200

change select * into select [*_]id if unused results

fixes #375
refs #361

---

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

diff --git a/Changelog b/Changelog
index 1dd414a..4cc8344 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ Icinga 1.0.x Change Log
 
 ENHANCEMENTS
 * idoutils: Spread the list of linked lists thinner (extend objects hash slots) (Opsera Ltd)
+* idoutils: change select * into select [*_]id if unused results
 
 FIXES
 * core: fix spurious dollar signs added to command_lines (Alexander Wirt)
diff --git a/module/idoutils/src/db.c b/module/idoutils/src/db.c
index 8e4c40e..e37041a 100644
--- a/module/idoutils/src/db.c
+++ b/module/idoutils/src/db.c
@@ -2994,7 +2994,7 @@ int ido2db_oci_prepared_statement_logentries_select(ndo2db_idi *idi) {
 
         //ndo2db_log_debug_info(NDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_oci_prepared_statement_() start\n");
 
-        if(asprintf(&buf, "SELECT * FROM %s WHERE instance_id=:X1 AND logentry_time=(SELECT unixts2date(:X2) FROM DUAL) AND logentry_data=:X3", 
+        if(asprintf(&buf, "SELECT id FROM %s WHERE instance_id=:X1 AND logentry_time=(SELECT unixts2date(:X2) FROM DUAL) AND logentry_data=:X3", 
                 ndo2db_db_tablenames[NDO2DB_DBTABLE_LOGENTRIES]) == -1) {
                         buf = NULL;
         }
diff --git a/module/idoutils/src/dbhandlers.c b/module/idoutils/src/dbhandlers.c
index f76a2ea..b0bd46e 100644
--- a/module/idoutils/src/dbhandlers.c
+++ b/module/idoutils/src/dbhandlers.c
@@ -162,7 +162,7 @@ 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 object_id 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) {
@@ -983,7 +983,7 @@ int ndo2db_handle_logentry(ndo2db_idi *idi) {
 	/* make sure we aren't importing a duplicate log entry... */
 #ifndef USE_ORACLE /* everything else will be libdbi */
 
-	if (asprintf(&buf, "SELECT * FROM %s WHERE instance_id='%lu' AND logentry_time=%s AND logentry_data='%s'", ndo2db_db_tablenames[NDO2DB_DBTABLE_LOGENTRIES], idi->dbinfo.instance_id, ts[0], es[0]) == -1)
+	if (asprintf(&buf, "SELECT logentry_id FROM %s WHERE instance_id='%lu' AND logentry_time=%s AND logentry_data='%s'", ndo2db_db_tablenames[NDO2DB_DBTABLE_LOGENTRIES], idi->dbinfo.instance_id, ts[0], es[0]) == -1)
 		buf = NULL;
 
 	if ((result = ndo2db_db_query(idi, buf)) == NDO_OK) {





More information about the icinga-checkins mailing list