summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2009-02-17 12:07:03 +0000
committerdeva <deva>2009-02-17 12:07:03 +0000
commit417532e9def7d5568ec9804a65078f2b42707a4a (patch)
treeef26189f18fe19a4b9a92a8b07b957688e6e0eca
parent8dde5e5e15434eb83e8514220973e3cf8b56a393 (diff)
Made the --with-db=no configure option actually compile without the db (even without an installed libpqxx).
-rw-r--r--server/configure.in13
-rw-r--r--server/src/database.cc4
-rw-r--r--server/src/pracrodaopgsql.cc27
-rw-r--r--server/src/pracrodaopgsql.h6
4 files changed, 19 insertions, 31 deletions
diff --git a/server/configure.in b/server/configure.in
index 013ea9a..9aad9f4 100644
--- a/server/configure.in
+++ b/server/configure.in
@@ -50,6 +50,11 @@ AC_ARG_WITH(db,
if test x$with_db == xno; then
AC_MSG_WARN([*** Building without db support!])
AC_DEFINE_UNQUOTED(WITHOUT_DB, , [The project is configured not to use the db])
+else
+ dnl ======================
+ dnl Check for libpqxx
+ dnl ======================
+ PKG_CHECK_MODULES(PQXX, libpqxx >= 2.6.8)
fi
AC_PROG_CXX
@@ -110,19 +115,11 @@ dnl Create the XML var i config.h
dnl ======================
AC_DEFINE_UNQUOTED(XML, "$MYPREFIX/share/xml", [The path to the xml files])
-
dnl ======================
dnl Check for getopt
dnl ======================
AC_HAVE_HEADERS(getopt.h)
-
-dnl ======================
-dnl Check for libpqxx
-dnl ======================
-PKG_CHECK_MODULES(PQXX, libpqxx >= 2.6.8)
-
-
dnl ======================
dnl Check for libconfig++
dnl ======================
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 <config.h>
+#ifndef WITHOUT_DB
+
#include <stdlib.h>
#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, <fields...>, %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 <config.h>
+
+#ifndef WITHOUT_DB
+
#include "pracrodao.h"
#include <pqxx/pqxx>
@@ -45,4 +49,6 @@ private:
pqxx::connection *conn;
};
+#endif/*WITHOUT_DB*/
+
#endif/*__PRACRO_PRACRODAOPGSQL_H__*/