]> git.ipfire.org Git - thirdparty/pdns.git/blame - modules/godbcbackend/sodbc.hh
Replace include guard ifdef/define with pragma once
[thirdparty/pdns.git] / modules / godbcbackend / sodbc.hh
CommitLineData
12471842
PL
1/*
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
e8c59f2d 22#pragma once
4f983d1b
PD
23#include <string>
24#include <vector>
25
26#include <sql.h>
27#include <sqlext.h>
28
29#include "pdns/backends/gsql/ssql.hh"
30
31//! ODBC SSql implementation for use with the Generic ODBC Backend.
32class SODBC : public SSql
33{
34private:
35
36
37 bool m_log; //!< Should we log?
38 bool m_busy; //!< Are we busy executing a query?
39
40 SQLHDBC m_connection; //!< Database connection handle.
41 SQLHENV m_environment; //!< Database environment handle
42
21143435 43 void testResult(SQLRETURN result, SQLSMALLINT type, SQLHANDLE handle, const std::string & message);
4f983d1b
PD
44
45public:
46 //! Default constructor.
47 /*!
48 This constructor connects to an ODBC datasource and makes sure it's ready to use.
49
50 \param dsn The ODBC DSN to use.
51 \param username Username to use.
52 \param password Password to use.
53 */
54 SODBC(
55 const std::string & dsn,
56 const std::string & username,
57 const std::string & password
58 );
59
60 //! Destructor.
61 virtual ~SODBC( void );
62
63 //! Sets the logging state.
1be1e84e 64 void setLog( bool state ) override;
4f983d1b 65
1be1e84e
AT
66 std::unique_ptr<SSqlStatement> prepare(const string& query, int nparams) override;
67 void execute(const string& query) override;
d57d7155
KM
68 void startTransaction() override;
69 void rollback() override;
70 void commit() override;
4f983d1b
PD
71
72 //! Returns an exception.
1be1e84e 73 SSqlException sPerrorException( const std::string & reason ) override;
4f983d1b
PD
74
75};