[icinga-checkins] icinga.org: icinga-core/tdressler/sqlite: idoutils: sqlite fix timestamp handling, skip timezone setting #3945

git at icinga.org git at icinga.org
Fri Apr 12 21:51:45 CEST 2013


Module: icinga-core
Branch: tdressler/sqlite
Commit: 71e2fbe0fd5350187d1e8206c22c4eefa8209d51
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=71e2fbe0fd5350187d1e8206c22c4eefa8209d51

Author: Thomas Dressler <tdressler at tdressler.net>
Date:   Fri Apr 12 21:48:22 2013 +0200

idoutils: sqlite fix timestamp handling,skip timezone setting #3945
refs #3945

---

 module/idoutils/src/db.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/module/idoutils/src/db.c b/module/idoutils/src/db.c
index accf290..e7ba05e 100644
--- a/module/idoutils/src/db.c
+++ b/module/idoutils/src/db.c
@@ -1435,6 +1435,7 @@ int ido2db_db_hello(ido2db_idi *idi) {
 	char *buf = NULL;
 	char *buf1 = NULL;
 	char *ts = NULL;
+	int set_tz= 0;
 #endif
 	int result = IDO_OK;
 	int have_instance = IDO_FALSE;
@@ -1631,6 +1632,10 @@ int ido2db_db_hello(ido2db_idi *idi) {
 	/* set session time zone to utc */
 	ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_db_hello() set session timezone\n");
 	switch (idi->dbinfo.server_type) {
+	       case IDO2DB_DBSERVER_SQLITE:
+	       case IDO2DB_DBSERVER_SQLITE3:
+	    	   set_tz=0;
+	    	   break;
 	       case IDO2DB_DBSERVER_MYSQL:
 		       if (asprintf(&buf, "SET SESSION TIME_ZONE='+00:00'")==-1) buf=NULL;
 		       break;
@@ -1640,7 +1645,9 @@ int ido2db_db_hello(ido2db_idi *idi) {
            default:
 	           break;
 	}
-	if (buf !=NULL) {
+	if (set_tz) {
+		//no tz settings for sqlite
+	  if (buf !=NULL) {
 		//ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_db_hello(timezone) execute %s\n",buf);
 		if (ido2db_db_query(idi, buf)== IDO_OK){
 			ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_db_hello(timezone) UTC set OK\n");
@@ -1650,10 +1657,10 @@ int ido2db_db_hello(ido2db_idi *idi) {
 		dbi_result_free(idi->dbinfo.dbi_result);
 		idi->dbinfo.dbi_result = NULL;
 		free(buf);
-	}else{
+	  }else{
 		ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_db_hello(timezone) Error: buffer allocation failed\n");
+	  }
 	}
-
 #endif
 
 	/* record initial connection information */





More information about the icinga-checkins mailing list