]>
Commit | Line | Data |
---|---|---|
12471842 PL |
1 | /* |
2 | * This file is part of PowerDNS or dnsdist. | |
3 | * Copyright -- PowerDNS.COM B.V. and its contributors | |
fc3c07b4 | 4 | * |
12471842 PL |
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. | |
fc3c07b4 | 8 | * |
12471842 PL |
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. | |
fc3c07b4 | 12 | * |
12471842 PL |
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. | |
fc3c07b4 | 17 | * |
12471842 PL |
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. | |
fc3c07b4 | 21 | */ |
0b67a76d BH |
22 | #ifndef SSQLITE3_HH |
23 | #define SSQLITE3_HH | |
24 | ||
25 | #include <sqlite3.h> | |
26 | #include "pdns/backends/gsql/ssql.hh" | |
27 | ||
28 | class SSQLite3 : public SSql | |
29 | { | |
30 | private: | |
31 | //! Pointer to the SQLite database instance. | |
32 | sqlite3 *m_pDB; | |
33 | ||
a464c196 | 34 | bool m_dolog; |
0f310932 | 35 | bool m_in_transaction; |
cb8934ae | 36 | static int busyHandler(void*, int); |
0b67a76d BH |
37 | protected: |
38 | public: | |
39 | //! Constructor. | |
ccca2f64 | 40 | SSQLite3( const std::string & database, bool creat=false ); |
0b67a76d BH |
41 | |
42 | //! Destructor. | |
6edbdc95 | 43 | ~SSQLite3(); |
0b67a76d | 44 | |
a59a9c23 | 45 | std::unique_ptr<SSqlStatement> prepare(const string& query, int nparams) override; |
0f310932 AT |
46 | void execute(const string& query); |
47 | void setLog(bool state); | |
0b67a76d | 48 | |
0f310932 AT |
49 | void startTransaction(); |
50 | void commit(); | |
51 | void rollback(); | |
0b67a76d | 52 | |
0f310932 | 53 | sqlite3 *db() { return this->m_pDB; }; |
0b67a76d | 54 | |
0f310932 | 55 | bool inTransaction() { return m_in_transaction; }; |
e237ea04 | 56 | |
0b67a76d BH |
57 | //! Used to create an backend specific exception message. |
58 | SSqlException sPerrorException( const std::string & reason ); | |
0b67a76d BH |
59 | }; |
60 | ||
61 | #endif // SSQLITE3_HH | |
62 |