From: Peter van Dijk Date: Fri, 9 Nov 2012 10:17:12 +0000 (+0000) Subject: add query-logging support for the bindbackend sqlite3 dnssec database. Closes #563... X-Git-Tag: auth-3.2-rc1~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e237ea0468d61a10fe02ed4fa1df61e14d9e7d39;p=pdns add query-logging support for the bindbackend sqlite3 dnssec database. Closes #563, submitted by Leen Besselink git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2874 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/backends/bind/binddnssec.cc b/pdns/backends/bind/binddnssec.cc index 732f9f97d..fc4c43eef 100644 --- a/pdns/backends/bind/binddnssec.cc +++ b/pdns/backends/bind/binddnssec.cc @@ -21,12 +21,15 @@ #include "bind-dnssec.schema.sqlite3.sql.h" #include #include "config.h" +#include "pdns/arguments.hh" #ifndef HAVE_SQLITE3 void Bind2Backend::setupDNSSEC() { if(!getArg("dnssec-db").empty()) throw runtime_error("bind-dnssec-db requires building PowerDNS with SQLite3"); + + d_dnssecdb->setLog(::arg().mustDo("query-logging")); } void Bind2Backend::createDNSSECDB(const string& fname) diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 561cc4074..88cf0734d 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -729,7 +729,6 @@ void GSQLBackend::lookup(const QType &qtype,const string &qname, DNSPacket *pkt_ snprintf(output,sizeof(output)-1, format.c_str(),sqlEscape(lcqname).c_str(),domain_id); } } - DLOG(L<< "Query: '" << output << "'"<doQuery(output); diff --git a/pdns/ssqlite3.cc b/pdns/ssqlite3.cc index 0af71ac66..5598b044a 100644 --- a/pdns/ssqlite3.cc +++ b/pdns/ssqlite3.cc @@ -4,10 +4,13 @@ // Copyright (C) 2003, Michel Stol // -#include "pdns/utility.hh" #include +#include #include "ssqlite3.hh" #include +#include +#include "pdns/logger.hh" +#include "misc.hh" #ifdef WIN32 # include @@ -31,6 +34,11 @@ SSQLite3::SSQLite3( const std::string & database, bool creat ) sqlite3_busy_handler(m_pDB, busyHandler, 0); } +void SSQLite3::setLog(bool state) +{ + s_dolog=state; +} + // Destructor. SSQLite3::~SSQLite3() { @@ -77,8 +85,12 @@ int SSQLite3::doQuery( const std::string & query, result_t & result ) int SSQLite3::doQuery( const std::string & query ) { const char *pTail; - // Execute the query. + + if(s_dolog) + L<= 3003009 if ( sqlite3_prepare_v2( m_pDB, query.c_str(), -1, &m_pStmt, &pTail ) != SQLITE_OK ) #else diff --git a/pdns/ssqlite3.hh b/pdns/ssqlite3.hh index 7b3c3cf11..42c2502f2 100644 --- a/pdns/ssqlite3.hh +++ b/pdns/ssqlite3.hh @@ -19,6 +19,8 @@ private: //! Pointer to the SQLite virtual machine executing a query. sqlite3_stmt *m_pStmt; + bool s_dolog; + static int busyHandler(void*, int); protected: public: @@ -47,6 +49,8 @@ public: //! Escapes the SQL query. std::string escape( const std::string & query ); + void setLog(bool state); + //! Used to create an backend specific exception message. SSqlException sPerrorException( const std::string & reason ); };