From: Christian Hofstaedtler Date: Tue, 15 Oct 2013 11:15:39 +0000 (+0200) Subject: Remove godbcbackend X-Git-Tag: rec-3.6.0-rc1~406^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed3d7b13e4bac4c2d6902e5ebeb864bfc7752bb4;p=pdns Remove godbcbackend --- diff --git a/configure.ac b/configure.ac index f9710c98d..322ef0be5 100644 --- a/configure.ac +++ b/configure.ac @@ -399,9 +399,6 @@ do [AC_DEFINE([HAVE_LDAP_SASL_BIND], 1, [Define to 1 if you have ldap_sasl_bind])] ) ;; - godbc ) - needunixodbc=yes - ;; opendbx) AC_CHECK_HEADERS([odbx.h], , [AC_MSG_ERROR([opendbx header (odbx.h) not found])]) AC_SUBST([LIBOPENDBX]) @@ -665,65 +662,6 @@ then AC_SUBST(CDB_CFLAGS) fi -if test "$needunixodbc" -then - AC_ARG_WITH(unixodbc, - AC_HELP_STRING([--with-unixodbc=],[root directory path of unixodbc installation]), - [UNIXODBC_lib_check="$withval/lib/unixodbc $with_unixodbc/lib $withval/lib" - UNIXODBC_inc_check="$withval/include/unixodbc"], - [UNIXODBC_lib_check="/usr/local/unixodbc/lib/unixodbc /usr/local/lib/unixodbc /usr/lib/unixodbc /usr/local/unixodbc/lib /usr/local/lib /opt/unixodbc/lib /usr/lib" - UNIXODBC_inc_check="/usr/local/unixodbc/include/unixodbc /usr/local/include/unixodbc/ /usr/local/include /opt/unixodbc/include/unixodbc /opt/unixodbc/include /usr/include/ /usr/include/unixodbc"]) - AC_ARG_WITH(unixodbc-lib, - AC_HELP_STRING([--with-unixodbc-lib=],[directory path of unixodbc library installation]), - [UNIXODBC_lib_check="$withval/lib/unixodbc $withval/unixodbc $withval"]) - AC_ARG_WITH(unixodbc-includes, - AC_HELP_STRING([--with-unixodbc-includes=],[directory path of unixodbc header installation]), - [UNIXODBC_inc_check="$withval/include $withval/include/unixodbc $withval/unixodbc $withval"]) - AC_MSG_CHECKING([for unixodbc library directory]) - UNIXODBC_libdir= - for m in $UNIXODBC_lib_check; do - if test -d "$m" && \ - (test -f "$m/libodbc.so" || test -f "$m/libodbc.a") - then - UNIXODBC_libdir=$m - break - fi - done - if test -z "$UNIXODBC_libdir"; then - AC_MSG_ERROR([Didn't find the unixodbc library dir in '$UNIXODBC_lib_check']) - fi - case "$UNIXODBC_libdir" in - /usr/lib ) UNIXODBC_lib="" ;; - /* ) UNIXODBC_lib="-L$UNIXODBC_libdir -Wl,-rpath,$UNIXODBC_libdir" - LDFLAGS="$UNIXODBC_lib $LDFLAGS" - ;; - * ) AC_MSG_ERROR([The unixodbc library directory ($UNIXODBC_libdir) must be an absolute path.]) ;; - esac - - AC_SUBST(UNIXODBC_lib) - AC_MSG_RESULT([$UNIXODBC_libdir]) - AC_MSG_CHECKING([for unixodbc include directory]) - UNIXODBC_incdir= - for m in $UNIXODBC_inc_check; do - if test -d "$m" && test -f "$m/sql.h" - then - UNIXODBC_incdir=$m - break - fi - done - if test -z "$UNIXODBC_incdir"; then - AC_MSG_ERROR([Didn't find the unixodbc include dir in '$UNIXODBC_inc_check']) - fi - case "$UNIXODBC_incdir" in - /* ) ;; - * ) AC_MSG_ERROR([The unixodbc include directory ($UNIXODBC_incdir) must be an absolute path.]) ;; - esac - AC_SUBST(UNIXODBC_incdir) - AC_MSG_RESULT([$UNIXODBC_incdir]) - -# LIBS="$LIBS -lunixodbc" -fi - for a in $modules do moduledirs="$moduledirs ${a}backend" @@ -764,7 +702,6 @@ pdns/backends/Makefile pdns/backends/bind/Makefile pdns/pdns pdns/precursor \ modules/gmysqlbackend/Makefile modules/db2backend/Makefile \ modules/geobackend/Makefile modules/opendbxbackend/Makefile \ modules/pipebackend/Makefile modules/oraclebackend/Makefile \ -modules/godbcbackend/Makefile \ modules/gpgsqlbackend/Makefile modules/ldapbackend/Makefile \ modules/gsqlite3backend/Makefile \ modules/goraclebackend/Makefile modules/mydnsbackend/Makefile \ diff --git a/modules/Makefile.am b/modules/Makefile.am index 8b7651cbe..8ab7ead98 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -1,2 +1,2 @@ SUBDIRS=@moduledirs@ -DIST_SUBDIRS=db2backend geobackend gmysqlbackend godbcbackend goraclebackend gpgsqlbackend gsqlite3backend ldapbackend luabackend mydnsbackend opendbxbackend oraclebackend pipebackend tinydnsbackend remotebackend randombackend +DIST_SUBDIRS=db2backend geobackend gmysqlbackend goraclebackend gpgsqlbackend gsqlite3backend ldapbackend luabackend mydnsbackend opendbxbackend oraclebackend pipebackend tinydnsbackend remotebackend randombackend diff --git a/modules/godbcbackend/Makefile.am b/modules/godbcbackend/Makefile.am deleted file mode 100644 index 7e95ac8dd..000000000 --- a/modules/godbcbackend/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -AM_CPPFLAGS=-I@UNIXODBC_incdir@ @THREADFLAGS@ -lib_LTLIBRARIES = libgodbcbackend.la - -EXTRA_DIST=OBJECTFILES OBJECTLIBS - -libgodbcbackend_la_SOURCES=godbcbackend.cc godbcbackend.hh \ - sodbc.hh sodbc.cc - - -libgodbcbackend_la_LDFLAGS=-module -avoid-version -lodbc diff --git a/modules/godbcbackend/OBJECTFILES b/modules/godbcbackend/OBJECTFILES deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/godbcbackend/OBJECTLIBS b/modules/godbcbackend/OBJECTLIBS deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/godbcbackend/godbcbackend.cc b/modules/godbcbackend/godbcbackend.cc deleted file mode 100644 index 22435070e..000000000 --- a/modules/godbcbackend/godbcbackend.cc +++ /dev/null @@ -1,106 +0,0 @@ -// The Generic ODBC Backend -// By Michel Stol - -#include "pdns/utility.hh" -#include -#include -#include - -#include "pdns/dns.hh" -#include "pdns/dnsbackend.hh" -#include "pdns/dnspacket.hh" -#include "pdns/ueberbackend.hh" -#include "pdns/pdnsexception.hh" -#include "pdns/logger.hh" -#include "pdns/arguments.hh" -#include "sodbc.hh" -#include "godbcbackend.hh" - - -// Connects to the database. -gODBCBackend::gODBCBackend (const std::string & mode, const std::string & suffix) : GSQLBackend( mode, suffix ) -{ - try - { - setDB( new SODBC( getArg( "datasource" ), getArg( "username" ), getArg( "password" ))); - } - catch( SSqlException & e ) - { - L< - -#include -#include "pdns/backends/gsql/gsqlbackend.hh" - -class gODBCBackend : public GSQLBackend -{ -private: -public: - //! Constructor that connects to the database, throws an exception if something went wrong. - gODBCBackend( const std::string & mode, const std::string & suffix ); - -}; - diff --git a/modules/godbcbackend/sodbc.cc b/modules/godbcbackend/sodbc.cc deleted file mode 100644 index 1fc674a48..000000000 --- a/modules/godbcbackend/sodbc.cc +++ /dev/null @@ -1,306 +0,0 @@ -// The Generic ODBC Backend -// By Michel Stol - -#include "pdns/utility.hh" -#include -#include "sodbc.hh" -#include -#include - -// Constructor. -SODBC::SODBC( - const std::string & dsn, - const std::string & username, - const std::string & password - ) -{ - SQLRETURN result; - - // Allocate an environment handle. - result = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_environment ); - testResult( result, "Could not allocate an environment handle." ); - - // Set ODBC version. (IEUW!) - result = SQLSetEnvAttr( m_environment, SQL_ATTR_ODBC_VERSION, reinterpret_cast< void * >( SQL_OV_ODBC3 ), 0 ); - testResult( result, "Could not set the ODBC version." ); - - // Allocate connection handle. - result = SQLAllocHandle( SQL_HANDLE_DBC, m_environment, &m_connection ); - testResult( result, "Could not allocate a connection handle." ); - - // Connect to the database. - char *l_dsn = strdup( dsn.c_str()); - char *l_username = strdup( username.c_str()); - char *l_password = strdup( password.c_str()); - - result = SQLConnect( m_connection, - reinterpret_cast< SQLTCHAR * >( l_dsn ), dsn.length(), - reinterpret_cast< SQLTCHAR * >( l_username ), username.length(), - reinterpret_cast< SQLTCHAR * >( l_password ), password.length()); - - free( l_dsn ); - free( l_username ); - free( l_password ); - - testResult( result, "Could not connect to ODBC datasource." ); - - // Allocate statement handle. - result = SQLAllocHandle( SQL_HANDLE_STMT, m_connection, &m_statement ); - testResult( result, "Could not allocate a statement handle." ); - - m_busy = false; - m_log = false; -} - - -// Destructor. -SODBC::~SODBC( void ) -{ - // Disconnect from database and free all used resources. - SQLFreeHandle( SQL_HANDLE_STMT, m_statement ); - - SQLDisconnect( m_connection ); - - SQLFreeHandle( SQL_HANDLE_DBC, m_connection ); - SQLFreeHandle( SQL_HANDLE_ENV, m_environment ); - - // Free all allocated column memory. - for ( int i = 0; i < m_columnInfo.size(); i++ ) - { - if ( m_columnInfo[ i ].m_pData ) - delete m_columnInfo[ i ].m_pData; - } -} - - -// Executes a query. -int SODBC::doQuery( const std::string & query ) -{ - SQLRETURN result; - char *tmp; - - if ( m_busy ) - throw SSqlException( "Tried to execute another query while being busy." ); - - tmp = strdup( query.c_str()); - - // Execute query. - result = SQLExecDirect( m_statement, reinterpret_cast< SQLTCHAR * >( tmp ), query.length()); - free( tmp ); - - testResult( result, "Could not execute query." ); - - // We are now busy. - m_busy = true; - - // Determine the number of columns. - SQLSMALLINT numColumns; - SQLNumResultCols( m_statement, &numColumns ); - - if ( numColumns == 0 ) - throw SSqlException( "Could not determine the number of columns." ); - - // Fill m_columnInfo. - m_columnInfo.clear(); - - column_t column; - SQLSMALLINT nullable; - SQLSMALLINT type; - - for ( SQLSMALLINT i = 1; i <= numColumns; i++ ) - { - SQLDescribeCol( m_statement, i, NULL, 0, NULL, &type, &column.m_size, NULL, &nullable ); - - if ( nullable == SQL_NULLABLE ) - column.m_canBeNull = true; - else - column.m_canBeNull = false; - - // Allocate memory. - switch ( type ) - { - case SQL_CHAR: - case SQL_VARCHAR: - case SQL_LONGVARCHAR: - column.m_type = SQL_C_CHAR; - column.m_pData = new SQLCHAR[ column.m_size ]; - break; - - case SQL_SMALLINT: - case SQL_INTEGER: - column.m_type = SQL_C_SLONG; - column.m_size = sizeof( long int ); - column.m_pData = new long int; - break; - - case SQL_REAL: - case SQL_FLOAT: - case SQL_DOUBLE: - column.m_type = SQL_C_DOUBLE; - column.m_size = sizeof( double ); - column.m_pData = new double; - break; - - default: - column.m_pData = NULL; - - } - - m_columnInfo.push_back( column ); - } - - return 0; -} - - -// Executes a query. -int SODBC::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(); -} - - -// Executes a command. -int SODBC::doCommand( const std::string & command ) -{ - SQLRETURN result; - char *tmp; - - if ( m_busy ) - throw SSqlException( "Tried to execute another query while being busy." ); - - tmp = strdup( command.c_str()); - - // Execute query. - result = SQLExecDirect( m_statement, reinterpret_cast< SQLTCHAR * >( tmp ), command.length()); - free( tmp ); - - testResult( result, "Could not execute query." ); - - SQLFreeStmt( m_statement, SQL_CLOSE ); - - return 0; -} - -// Escapes a SQL string. -std::string SODBC::escape( const std::string & name ) -{ - std::string a; - - for( std::string::const_iterator i = name.begin(); i != name.end(); ++i ) - { - if( *i == '\'' || *i == '\\' ) - a += '\\'; - a += *i; - } - - return a; -} - - -// Returns the content of a row. -bool SODBC::getRow( row_t & row ) -{ - SQLRETURN result; - - row.clear(); - - result = SQLFetch( m_statement ); - if ( result == SQL_SUCCESS || result == SQL_SUCCESS_WITH_INFO ) - { - // We've got a data row, now lets get the results. - SQLLEN len; - for ( int i = 0; i < m_columnInfo.size(); i++ ) - { - if ( m_columnInfo[ i ].m_pData == NULL ) - continue; - - // Clear buffer. - memset( m_columnInfo[ i ].m_pData, 0, m_columnInfo[ i ].m_size ); - - SQLGetData( m_statement, i + 1, m_columnInfo[ i ].m_type, m_columnInfo[ i ].m_pData, m_columnInfo[ i ].m_size, &len ); - - if ( len == SQL_NULL_DATA ) - { - // Column is NULL, so we can skip the converting part. - row.push_back( "" ); - continue; - } - - // Convert the data into strings. - std::ostringstream str; - - switch ( m_columnInfo[ i ].m_type ) - { - case SQL_C_CHAR: - row.push_back( reinterpret_cast< char * >( m_columnInfo[ i ].m_pData )); - break; - - case SQL_C_SSHORT: - case SQL_C_SLONG: - str << *( reinterpret_cast< long * >( m_columnInfo[ i ].m_pData )); - row.push_back( str.str()); - - break; - - case SQL_C_DOUBLE: - str << *( reinterpret_cast< double * >( m_columnInfo[ i ].m_pData )); - row.push_back( str.str()); - - break; - - default: - // Eh? - row.push_back( "" ); - - } - } - - // Done! - return true; - } - - // No further results, or error. - m_busy = false; - - // Free all allocated column memory. - for ( int i = 0; i < m_columnInfo.size(); i++ ) - { - if ( m_columnInfo[ i ].m_pData ) - delete m_columnInfo[ i ].m_pData; - } - - SQLFreeStmt( m_statement, SQL_CLOSE ); - - return false; -} - - -// Sets the log state. -void SODBC::setLog( bool state ) -{ - m_log = state; -} - - -// Returns an exception. -SSqlException SODBC::sPerrorException( const std::string & reason ) -{ - return SSqlException( reason ); -} - - -// Tests the result. -void SODBC::testResult( SQLRETURN result, const std::string & message ) -{ - if ( result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO ) - throw SSqlException( message ); -} diff --git a/modules/godbcbackend/sodbc.hh b/modules/godbcbackend/sodbc.hh deleted file mode 100644 index 2c046c42c..000000000 --- a/modules/godbcbackend/sodbc.hh +++ /dev/null @@ -1,90 +0,0 @@ -// The Generic ODBC Backend -// By Michel Stol - -#ifndef SODBC_HH -#define SODBC_HH - -#include -#include - -// The following line makes Bert puke every time he sees it. -//#define WINDOWS_LEAN_AND_MEAN -//#include -#include -#include - -#include "pdns/backends/gsql/ssql.hh" - - -//! ODBC SSql implementation for use with the Generic ODBC Backend. -class SODBC : public SSql -{ -private: - //! Column type. - struct column_t - { - SQLSMALLINT m_type; //!< Type of the column. - SQLULEN m_size; //!< Column size. - SQLPOINTER m_pData; //!< Pointer to the memory where to store the data. - bool m_canBeNull; //!< Can this column be null? - }; - - bool m_log; //!< Should we log? - bool m_busy; //!< Are we busy executing a query? - - SQLHDBC m_connection; //!< Database connection handle. - SQLHENV m_environment; //!< Database environment handle - SQLHSTMT m_statement; //!< Database statement handle. - - //! Column info. - std::vector< column_t > m_columnInfo; - - - //! Throws a SQLException if the result has an error value. - void testResult( SQLRETURN result, const std::string & message = "" ); - - -public: - //! Default constructor. - /*! - This constructor connects to an ODBC datasource and makes sure it's ready to use. - - \param database The database where the data is located (not used). - \param dsn The ODBC DSN to use. - \param username Username to use. - \param password Password to use. - */ - SODBC( - const std::string & dsn = "PowerDNS", - const std::string & username = "", - const std::string & password = "" - ); - - //! Destructor. - virtual ~SODBC( void ); - - //! Executes a query. - int doQuery( const std::string & query ); - - //! Executes a query and stores the result. - int doQuery( const std::string & query, result_t & result ); - - //! Executes a command. - int doCommand( const std::string & command ); - - //! Escapes a SQL string. - std::string escape( const std::string & name ); - - //! Returns a row. - bool getRow( row_t & row ); - - //! Sets the logging state. - void setLog( bool state ); - - //! Returns an exception. - SSqlException sPerrorException( const std::string & reason ); - -}; - - -#endif // SODBC_HH diff --git a/pdns/docs/pdns.xml b/pdns/docs/pdns.xml index b891d33dd..2f6e4f07f 100755 --- a/pdns/docs/pdns.xml +++ b/pdns/docs/pdns.xml @@ -17922,7 +17922,7 @@ insert into domains (id,name,type) values (domains_id_sequence.nextval,'example. Do not wrap statements in quotes as this will not work. Besides the query related settings, the following configuration options are available, where one should substitute 'gmysql', - 'gpgsql', 'godbc' or 'goracle' for the prefix 'backend'. So + 'gpgsql', or 'goracle' for the prefix 'backend'. So 'backend-dbname' can stand for 'gpgsql-dbname' or 'gmysql-dbname' etc.