[icinga-checkins] icinga.org: icinga-core/next: idoutils: fix postgresql limit x, y -> limit y offset x

git at icinga.org git at icinga.org
Sun Jul 7 18:13:21 CEST 2013


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

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Mon Jul  1 22:47:35 2013 +0200

idoutils: fix postgresql limit x,y -> limit y offset x

refs #4367

---

 module/idoutils/src/dbhandlers.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/module/idoutils/src/dbhandlers.c b/module/idoutils/src/dbhandlers.c
index a7d0539..a712e55 100644
--- a/module/idoutils/src/dbhandlers.c
+++ b/module/idoutils/src/dbhandlers.c
@@ -491,8 +491,16 @@ int ido2db_get_cached_object_ids(ido2db_idi *idi) {
 	stride = 2500;
 
 	for (;;) {
-		if (asprintf(&buf, "SELECT object_id, objecttype_id, name1, name2 FROM %s WHERE instance_id=%lu LIMIT %lu, %lu", ido2db_db_tablenames[IDO2DB_DBTABLE_OBJECTS], idi->dbinfo.instance_id, offset, stride) == -1)
-			buf = NULL;
+                switch (idi->dbinfo.server_type) {
+                case IDO2DB_DBSERVER_PGSQL:
+			if (asprintf(&buf, "SELECT object_id, objecttype_id, name1, name2 FROM %s WHERE instance_id=%lu LIMIT %lu OFFSET %lu", ido2db_db_tablenames[IDO2DB_DBTABLE_OBJECTS], idi->dbinfo.instance_id, stride, offset) == -1)
+				buf = NULL;
+			break;
+		default:
+			if (asprintf(&buf, "SELECT object_id, objecttype_id, name1, name2 FROM %s WHERE instance_id=%lu LIMIT %lu, %lu", ido2db_db_tablenames[IDO2DB_DBTABLE_OBJECTS], idi->dbinfo.instance_id, offset, stride) == -1)
+				buf = NULL;
+			break;
+		}
 
 		if ((result = ido2db_db_query(idi, buf)) == IDO_OK) {
 			if (dbi_result_get_numrows(idi->dbinfo.dbi_result) == 0)
@@ -501,7 +509,7 @@ int ido2db_get_cached_object_ids(ido2db_idi *idi) {
 			while (idi->dbinfo.dbi_result) {
 				if (dbi_result_next_row(idi->dbinfo.dbi_result)) {
 					char *name2;
-					
+
 					object_id = dbi_result_get_ulonglong(idi->dbinfo.dbi_result, "object_id");
 					objecttype_id = dbi_result_get_ulonglong(idi->dbinfo.dbi_result, "objecttype_id");
 





More information about the icinga-checkins mailing list