From: Bert Hubert Date: Sat, 6 Oct 2012 18:20:35 +0000 (+0000) Subject: sqlite2 backend had been broken for a while now, and it is ancient. bye bye. Closes... X-Git-Tag: auth-3.2-rc1~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8557a62e4ea91acfe991ebb9aabf90ea9d82fc8;p=thirdparty%2Fpdns.git sqlite2 backend had been broken for a while now, and it is ancient. bye bye. Closes ticket 565. git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2773 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/build-scripts/rpm-build-instruction b/build-scripts/rpm-build-instruction index 11afd52a60..488b400d11 100755 --- a/build-scripts/rpm-build-instruction +++ b/build-scripts/rpm-build-instruction @@ -1,7 +1,7 @@ #!/bin/sh #LIBS="-lkrb5 -lk5crypto -lpgport -lgssapi_krb5 -lkrb5support -lgssapi_krb5 -lcom_err -lnsl -lresolv" \ CC="ccache gcc" CXX="ccache g++" CPPFLAGS=-I/usr/local/include/botan-1.10 ./configure \ - --with-modules="gmysql gpgsql gsqlite gsqlite3 pipe geo lua" \ + --with-modules="gmysql gpgsql gsqlite3 pipe geo lua" \ --with-dynmodules="" \ --enable-static-binaries \ --with-pgsql-lib=/opt/postgresql/lib --with-pgsql-includes=/opt/postgresql/include \ diff --git a/build-scripts/tar-gz-build-instruction b/build-scripts/tar-gz-build-instruction index df19f41cf8..caa421c2f7 100755 --- a/build-scripts/tar-gz-build-instruction +++ b/build-scripts/tar-gz-build-instruction @@ -2,6 +2,6 @@ rm -f $(find . -name "*~") && ./bootstrap && ./configure \ --with-pgsql-lib=/opt/postgresql/lib --with-pgsql-includes=/opt/postgresql/include \ ---with-modules="mydns gmysql mongodb lua gpgsql xdb pipe oracle pipe db2 ldap gsqlite gsqlite3 geo goracle opendbx godbc" \ +--with-modules="mydns gmysql mongodb lua gpgsql xdb pipe oracle pipe db2 ldap gsqlite3 geo goracle opendbx godbc" \ --with-dynmodules="" && make dist \ No newline at end of file diff --git a/configure.ac b/configure.ac index a5d85fae5a..92d46cd631 100644 --- a/configure.ac +++ b/configure.ac @@ -312,9 +312,6 @@ do gpgsql ) needpgsql=yes ;; - gsqlite ) - needsqlite=yes - ;; gsqlite3 ) needsqlite3=yes ;; @@ -664,7 +661,7 @@ modules/pipebackend/Makefile modules/oraclebackend/Makefile \ modules/xdbbackend/Makefile modules/godbcbackend/Makefile \ modules/mongodbbackend/Makefile \ modules/gpgsqlbackend/Makefile modules/ldapbackend/Makefile \ -modules/gsqlitebackend/Makefile modules/gsqlite3backend/Makefile \ +modules/gsqlite3backend/Makefile \ modules/goraclebackend/Makefile modules/mydnsbackend/Makefile \ modules/luabackend/Makefile modules/tinydnsbackend/Makefile \ modules/remotebackend/Makefile) diff --git a/modules/gsqlitebackend/Makefile.am b/modules/gsqlitebackend/Makefile.am deleted file mode 100644 index 66b930e062..0000000000 --- a/modules/gsqlitebackend/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -AM_CPPFLAGS=@THREADFLAGS@ $(BOOST_CPPFLAGS) -lib_LTLIBRARIES = libgsqlitebackend.la - -EXTRA_DIST=OBJECTFILES OBJECTLIBS - -INCLUDES=-I@SQLITE_incdir@ - -libgsqlitebackend_la_SOURCES=gsqlitebackend.cc gsqlitebackend.hh \ - ssqlite.hh ssqlite.cc - - -libgsqlitebackend_la_LDFLAGS=-module -avoid-version -lsqlite diff --git a/modules/gsqlitebackend/OBJECTFILES b/modules/gsqlitebackend/OBJECTFILES deleted file mode 100644 index 4673a62a5a..0000000000 --- a/modules/gsqlitebackend/OBJECTFILES +++ /dev/null @@ -1 +0,0 @@ -gsqlitebackend.o ssqlite.o \ No newline at end of file diff --git a/modules/gsqlitebackend/OBJECTLIBS b/modules/gsqlitebackend/OBJECTLIBS deleted file mode 100644 index beae84a8a3..0000000000 --- a/modules/gsqlitebackend/OBJECTLIBS +++ /dev/null @@ -1 +0,0 @@ --lsqlite \ No newline at end of file diff --git a/modules/gsqlitebackend/gsqlitebackend.cc b/modules/gsqlitebackend/gsqlitebackend.cc deleted file mode 100644 index c92cabb6e9..0000000000 --- a/modules/gsqlitebackend/gsqlitebackend.cc +++ /dev/null @@ -1,112 +0,0 @@ - -// -// SQLite backend for PowerDNS -// Copyright (C) 2003, Michel Stol -// - -#include "pdns/utility.hh" -#include -#include -#include -#include - -#include "pdns/dns.hh" -#include "pdns/dnsbackend.hh" -#include "pdns/dnspacket.hh" -#include "pdns/ueberbackend.hh" -#include "pdns/ahuexception.hh" -#include "pdns/logger.hh" -#include "pdns/arguments.hh" -#include "ssqlite.hh" -#include "gsqlitebackend.hh" -#include - -// Connects to the database. -gSQLiteBackend::gSQLiteBackend( const std::string & mode, const std::string & suffix ) : GSQLBackend( mode, suffix ) -{ - try - { - setDB( new SSQLite( getArg( "database" ))); - } - catch( SSqlException & e ) - { - L << Logger::Error << mode << ": connection failed: " << e.txtReason() << std::endl; - throw AhuException( "Unable to launch " + mode + " connection: " + e.txtReason()); - } - - L << Logger::Warning << mode << ": connection to '"< -// - -#ifndef GSQLITEBACKEND_HH -#define GSQLITEBACKEND_HH - -#include -#include "pdns/backends/gsql/gsqlbackend.hh" - -//! The gSQLiteBackend retrieves it's data from a SQLite database (http://www.sqlite.org/) -class gSQLiteBackend : public GSQLBackend -{ -private: -protected: -public: - //! Constructs the backend, throws an exception if it failed.. - gSQLiteBackend( const std::string & mode, const std::string & suffix ); - virtual string sqlEscape(const string &name); -}; - -#endif // GSQLITEBACKEND_HH diff --git a/modules/gsqlitebackend/ssqlite.cc b/modules/gsqlitebackend/ssqlite.cc deleted file mode 100644 index 178d68cd37..0000000000 --- a/modules/gsqlitebackend/ssqlite.cc +++ /dev/null @@ -1,154 +0,0 @@ - -// -// SQLite backend for PowerDNS -// Copyright (C) 2003, Michel Stol -// - -#include "pdns/utility.hh" -#include -#include "ssqlite.hh" -#include - -#ifdef WIN32 -# include -# define access _access -# define F_OK 0 -#else // WIN32 -# include -#endif // Unix - -// Constructor. -SSQLite::SSQLite( const std::string & database ) -{ - // Open the database connection. - if ( access( database.c_str(), F_OK ) == -1 ) - throw sPerrorException( "SQLite database does not exist yet" ); - - m_pDB = sqlite_open( database.c_str(), 0, NULL ); - if ( !m_pDB ) - throw sPerrorException( "Could not connect to the SQLite database '" + database + "'" ); -} - - -// Destructor. -SSQLite::~SSQLite( void ) -{ - sqlite_close( m_pDB ); -} - - -// Constructs a SSqlException object. -SSqlException SSQLite::sPerrorException( const std::string & reason ) -{ - return SSqlException( reason ); -} - - -// Performs a query. -int SSQLite::doQuery( const std::string & query, result_t & result ) -{ - result.clear(); - - doQuery( query ); - - row_t row; - while( getRow( row )) - result.push_back( row ); - - return result.size(); -} - - -// Performs a query. -int SSQLite::doQuery( const std::string & query ) -{ - const char *pOut; - - // Execute the query. - char *pError = NULL; - if ( sqlite_compile( m_pDB, query.c_str(), &pOut, &m_pVM, &pError ) != SQLITE_OK ) - throw sPerrorException( "Could not create SQLite VM for query" ); - - if ( !m_pVM ) { - std::string report( "Unable to compile SQLite statement" ); - - if( pError ) - { - report += string( ": " ) + pError; - sqlite_freemem( pError ); - } - - sPerrorException( report ); - } - return 0; -} - - -// Returns a row from the result set. -bool SSQLite::getRow( row_t & row ) -{ - int numCols; - int rc; - const char **ppData; - const char **ppColumnNames; - - row.clear(); - - do - { - rc = sqlite_step( m_pVM, &numCols, &ppData, &ppColumnNames ); - - if ( rc == SQLITE_BUSY ) - Utility::usleep( 250 ); // FIXME: Should this be increased, decreased, or is it Just Right? :) - else - break; - - } while ( true ); - - if ( rc == SQLITE_ROW ) - { - // Another row received, process it. - for ( int i = 0; i < numCols; i++ ) - { - if ( ppData[ i ] ) - row.push_back( ppData[ i ] ); - else - row.push_back( "" ); // NULL value. - } - - return true; - } - - if ( rc == SQLITE_DONE ) - { - // We're done, clean up. - sqlite_finalize( m_pVM, NULL ); - m_pVM = NULL; - - return false; - } - - // Something went wrong, complain. - throw sPerrorException( "Error while retrieving SQLite query results" ); - - // Prevent some compilers from complaining. - return false; -} - - -// Escape a SQL query. -std::string SSQLite::escape( const std::string & name) -{ - std::string a; - - for( std::string::const_iterator i = name.begin(); i != name.end(); ++i ) - { - if( *i == '\'') - a += '\''; - - a += *i; - } - - return a; -} - diff --git a/modules/gsqlitebackend/ssqlite.hh b/modules/gsqlitebackend/ssqlite.hh deleted file mode 100644 index 096f439ad2..0000000000 --- a/modules/gsqlitebackend/ssqlite.hh +++ /dev/null @@ -1,56 +0,0 @@ - -// -// SQLite backend for PowerDNS -// Copyright (C) 2003, Michel Stol -// - -#ifndef SSQLITE_HH -#define SSQLITE_HH - -#include -#include "pdns/backends/gsql/ssql.hh" - -class SSQLite : public SSql -{ -private: - //! Pointer to the SQLite database instance. - sqlite *m_pDB; - - //! Pointer to the SQLite virtual machine executing a query. - sqlite_vm *m_pVM; - -protected: -public: - //! Constructor. - SSQLite( const std::string & database ); - - //! Destructor. - ~SSQLite( void ); - - //! Performs a query and puts answers in result - int doQuery( const std::string & query, result_t & result ); - - //! Performs a query, caller can retrieve answers with getRow - int doQuery( const std::string & query ); - - //! Performs a command that does not return rows - int doCommand( const std::string & query ) - { - result_t result; - return doQuery(query, result); // 'result' is necessary to force doQuery to do the work, closing Debian bug 280359 - } - - - //! Returns a row from a result set. - bool getRow( row_t & row ); - - //! Escapes the SQL query. - std::string escape( const std::string & query ); - - //! Used to create an backend specific exception message. - SSqlException sPerrorException( const std::string & reason ); - -}; - -#endif // SSQLITE_HH -