lib_LTLIBRARIES = libgmysqlbackend.la
+EXTRA_DIST=OBJECTFILES OBJECTLIBS
+
INCLUDES=-I@MYSQL_incdir@
libgmysqlbackend_la_SOURCES=gmysqlbackend.cc gmysqlbackend.hh \
YACC = @YACC@
am__include = @am__include@
am__quote = @am__quote@
-domysql = @domysql@
-dopgsql = @dopgsql@
install_sh = @install_sh@
moduledirs = @moduledirs@
modulelibs = @modulelibs@
moduleobjects = @moduleobjects@
+programdescend = @programdescend@
socketdir = @socketdir@
lib_LTLIBRARIES = libgmysqlbackend.la
+EXTRA_DIST = OBJECTFILES OBJECTLIBS
+
INCLUDES = -I@MYSQL_incdir@
libgmysqlbackend_la_SOURCES = gmysqlbackend.cc gmysqlbackend.hh \
#include <string>
#include <map>
-#include "ssql.hh"
+
#include "pdns/backends/gsql/gsqlbackend.hh"
using namespace std;
/* Copyright 2001 Netherlabs BV, bert.hubert@netherlabs.nl. See LICENSE
for more information.
- $Id: smysql.hh,v 1.2 2002/11/29 15:20:08 ahu Exp $ */
+ $Id: smysql.hh,v 1.3 2002/12/19 16:28:31 ahu Exp $ */
#ifndef SMYSQL_HH
#define SMYSQL_HH
#include <mysql.h>
-#include "ssql.hh"
+#include "pdns/backends/gsql/ssql.hh"
class SMySQL : public SSql
{
+++ /dev/null
-/* Copyright 200w Netherlabs BV, bert.hubert@netherlabs.nl. See LICENSE
- for more information.
- $Id: spgsql.cc,v 1.2 2002/12/16 18:02:24 ahu Exp $ */
-#include "spgsql.hh"
-#include <string>
-#include <iostream>
-#include "pdns/logger.hh"
-#include "pdns/dns.hh"
-using namespace std;
-
-bool SPgSQL::s_dolog;
-
-SPgSQL::SPgSQL(const string &database, const string &host, const string &msocket, const string &user,
- const string &password)
-{
- string connectstr;
-
- connectstr="dbname=";
- connectstr+=database;
- connectstr+=" user=";
- connectstr+=user;
-
- if(!host.empty())
- connectstr+=" host="+host;
-
- if(!password.empty())
- connectstr+=" password="+password;
-
- d_db=new PgDatabase(connectstr.c_str());
-
- // Check to see that the backend connection was successfully made
- if (d_db->ConnectionBad() ) {
- throw sPerrorException("Unable to connect to database");
- }
-
-}
-
-void SPgSQL::setLog(bool state)
-{
- s_dolog=state;
-}
-
-SPgSQL::~SPgSQL()
-{
- delete d_db;
-}
-
-SSqlException SPgSQL::sPerrorException(const string &reason)
-{
- return SSqlException(reason+string(": ")+d_db->ErrorMessage());
-}
-
-int SPgSQL::doQuery(const string &query)
-{
- if(s_dolog)
- L<<Logger::Warning<<"Query: "<<query<<endl;
-
- if(!d_db->Exec(query.c_str())) {
- throw sPerrorException("PostgreSQL failed to execute command");
- }
- d_count=0;
- return 0;
-}
-
-int SPgSQL::doQuery(const string &query, result_t &result)
-{
- result.clear();
- if(s_dolog)
- L<<Logger::Warning<<"Query: "<<query<<endl;
-
- if(!d_db->ExecTuplesOk(query.c_str()))
- throw sPerrorException("gPgSQLBackend failed to execute command that expected results");
- d_count=0;
-
- row_t row;
- while(getRow(row))
- result.push_back(row);
-
- return result.size();
-}
-
-bool SPgSQL::getRow(row_t &row)
-{
- row.clear();
-
- if(d_count>=d_db->Tuples())
- return false;
-
- for(int i=0;i<d_db->Fields();i++)
- row.push_back(d_db->GetValue(d_count,i) ?: "");
- d_count++;
- return true;
-}
-
-string SPgSQL::escape(const string &name)
-{
- string a;
-
- for(string::const_iterator i=name.begin();i!=name.end();++i) {
- if(*i=='\'' || *i=='\\')
- a+='\\';
- a+=*i;
- }
- return a;
-}
+++ /dev/null
-/* Copyright 2001 Netherlabs BV, bert.hubert@netherlabs.nl. See LICENSE
- for more information.
- $Id: spgsql.hh,v 1.1 2002/11/27 15:23:16 ahu Exp $ */
-#ifndef SPGSQL_HH
-#define SPGSQL_HH
-#include <libpq++.h>
-#include "ssql.hh"
-
-class SPgSQL : public SSql
-{
-public:
- SPgSQL(const string &database, const string &host="",
- const string &msocket="",const string &user="",
- const string &password="");
-
- ~SPgSQL();
-
- SSqlException sPerrorException(const string &reason);
- int doQuery(const string &query, result_t &result);
- int doQuery(const string &query);
- bool getRow(row_t &row);
- string escape(const string &str);
- void setLog(bool state);
-private:
- PgDatabase *d_db;
- int d_count;
- static bool s_dolog;
-};
-
-#endif /* SPGSQL_HH */
+++ /dev/null
-/* Copyright 2001 Netherlabs BV, bert.hubert@netherlabs.nl. See LICENSE
- for more information.
- $Id: ssql.hh,v 1.1 2002/11/27 15:23:16 ahu Exp $ */
-#ifndef SSQL_HH
-#define SSQL_HH
-
-#include <string>
-#include <vector>
-using namespace std;
-
-
-class SSqlException
-{
-public:
- SSqlException(const string &reason)
- {
- d_reason=reason;
- }
-
- string txtReason()
- {
- return d_reason;
- }
-private:
- string d_reason;
-};
-
-class SSql
-{
-public:
- typedef vector<string> row_t;
- typedef vector<row_t> result_t;
- virtual SSqlException sPerrorException(const string &reason)=0;
- virtual int doQuery(const string &query, result_t &result)=0;
- virtual int doQuery(const string &query)=0;
- virtual bool getRow(row_t &row)=0;
- virtual string escape(const string &name)=0;
- virtual void setLog(bool state){}
- virtual ~SSql(){};
-};
-
-#endif /* SSQL_HH */