]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/store/postgresql/postgresql_store_utils.cpp
Massive refactoring.
[stg.git] / projects / stargazer / plugins / store / postgresql / postgresql_store_utils.cpp
index 28a17895b0eb770ccccf6c18813957ed586815f4..f5dec89ff5ec223159423d3cabe3d2846157ed6e 100644 (file)
 
 #include <libpq-fe.h>
 
-#include "common.h"
-
+#include "stg/common.h"
 #include "postgresql_store.h"
 
+extern volatile time_t stgTime;
+
 int POSTGRESQL_STORE::StartTransaction() const
 {
 PGresult * result = PQexec(connection, "BEGIN");
@@ -101,7 +102,7 @@ if (error)
     {
     strError = PQerrorMessage(connection);
     printfd(__FILE__, "POSTGRESQL_STORE::EscapeString(): '%s'\n", strError.c_str());
-    delete buf;
+    delete[] buf;
     return -1;
     }
 
@@ -111,24 +112,23 @@ delete[] buf;
 return 0;
 }
 
-std::string POSTGRESQL_STORE::Int2TS(uint32_t ts) const
+std::string POSTGRESQL_STORE::Int2TS(time_t ts) const
 {
 char buf[32];
 struct tm brokenTime;
-time_t tt = ts;
 
 brokenTime.tm_wday = 0;
 brokenTime.tm_yday = 0;
 brokenTime.tm_isdst = 0;
 
-gmtime_r(&tt, &brokenTime);
+gmtime_r(&ts, &brokenTime);
 
 strftime(buf, 32, "%Y-%m-%d %H:%M:%S", &brokenTime);
 
 return buf;
 }
 
-uint32_t POSTGRESQL_STORE::TS2Int(const std::string & ts) const
+time_t POSTGRESQL_STORE::TS2Int(const std::string & ts) const
 {
 struct tm brokenTime;