From 417532e9def7d5568ec9804a65078f2b42707a4a Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 17 Feb 2009 12:07:03 +0000 Subject: Made the --with-db=no configure option actually compile without the db (even without an installed libpqxx). --- server/src/database.cc | 4 ++++ server/src/pracrodaopgsql.cc | 27 ++++----------------------- server/src/pracrodaopgsql.h | 6 ++++++ 3 files changed, 14 insertions(+), 23 deletions(-) (limited to 'server/src') diff --git a/server/src/database.cc b/server/src/database.cc index 74579c1..6a25f93 100644 --- a/server/src/database.cc +++ b/server/src/database.cc @@ -35,15 +35,19 @@ Database::Database(std::string _backend, std::string _host, std::string _port, std::string _user, std::string _passwd, std::string _dbname) { +#ifndef WITHOUT_DB dao = NULL; if(_backend == "pgsql") { PRACRO_DEBUG(db, "construct(%s, %s, %s, %s, %s)\n", _host.c_str(), _port.c_str(), _user.c_str(), _passwd.c_str(), _dbname.c_str()); dao = new PracroDAOPgsql(_host, _port, _user, _passwd, _dbname); } +#endif/*WITHOUT_DB*/ } Database::~Database() { +#ifndef WITHOUT_DB if(dao) delete dao; +#endif/*WITHOUT_DB*/ } diff --git a/server/src/pracrodaopgsql.cc b/server/src/pracrodaopgsql.cc index 05cd46d..c2e65bc 100644 --- a/server/src/pracrodaopgsql.cc +++ b/server/src/pracrodaopgsql.cc @@ -36,9 +36,10 @@ * UPDATE transactions SET uid = oid; * INSERT INTO fieldnames (name, description, timestamp) VALUES ('journal.resume', 'Journal resume text', (SELECT EXTRACT(EPOCH FROM now())::integer)); */ - #include +#ifndef WITHOUT_DB + #include #include "debug.h" @@ -72,7 +73,6 @@ void PracroDAOPgsql::commitTransaction(std::string user, std::string cpr, Macro std::string macro = _macro.attributes["name"]; std::stringstream timestamp; timestamp << now; -#ifndef WITHOUT_DB std::string ts; try { pqxx::work W(*conn); @@ -126,15 +126,6 @@ void PracroDAOPgsql::commitTransaction(std::string user, std::string cpr, Macro } catch(std::exception &e) { PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); } -#else -#ifdef WITH_DEBUG - std::map< std::string, std::string >::iterator i = fields.begin(); - while(i != fields.end()) { - PRACRO_DEBUG(db, "Storing field '%s': '%s'\n", i->first, i->second); - i++; - } -#endif/*WITH_DEBUG*/ -#endif/*WITHOUT_DB*/ } @@ -165,7 +156,6 @@ Values PracroDAOPgsql::getLatestValues(std::string cpr, Macro *macro, Fieldnames if(!conn) PRACRO_DEBUG(db, "No pgsql connection\n"); Values values; -#ifndef WITHOUT_DB std::string query; std::stringstream soldest; soldest << oldest; try { @@ -220,11 +210,6 @@ Values PracroDAOPgsql::getLatestValues(std::string cpr, Macro *macro, Fieldnames } catch (std::exception &e) { PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str()); } -#else -#ifdef WITH_DEBUG - PRACRO_DEBUG(db, "getLatestValues(%s, , %ld) -- not implemented without database...\n", cpr.c_str(), oldest); -#endif/*WITH_DEBUG*/ -#endif/*WITHOUT_DB*/ return values; } @@ -232,7 +217,6 @@ Values PracroDAOPgsql::getLatestValues(std::string cpr, Macro *macro, Fieldnames unsigned PracroDAOPgsql::nrOfCommits(std::string cpr, std::string macroname, time_t oldest) { -#ifndef WITHOUT_DB std::string query; std::stringstream soldest; soldest << oldest; try { @@ -254,11 +238,8 @@ unsigned PracroDAOPgsql::nrOfCommits(std::string cpr, std::string macroname, tim } catch (std::exception &e) { PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str()); } -#else -#ifdef WITH_DEBUG - PRACRO_DEBUG(db, "Returning 0 commits without database\n"); -#endif/*WITH_DEBUG*/ -#endif/*WITHOUT_DB*/ + return 0; } +#endif/*WITHOUT_DB*/ diff --git a/server/src/pracrodaopgsql.h b/server/src/pracrodaopgsql.h index 7218a19..90498e9 100644 --- a/server/src/pracrodaopgsql.h +++ b/server/src/pracrodaopgsql.h @@ -28,6 +28,10 @@ #ifndef __PRACRO_PRACRODAOPGSQL_H__ #define __PRACRO_PRACRODAOPGSQL_H__ +#include + +#ifndef WITHOUT_DB + #include "pracrodao.h" #include @@ -45,4 +49,6 @@ private: pqxx::connection *conn; }; +#endif/*WITHOUT_DB*/ + #endif/*__PRACRO_PRACRODAOPGSQL_H__*/ -- cgit v1.2.3