]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/ssqlite3.hh
Update rules-actions.rst
[thirdparty/pdns.git] / pdns / ssqlite3.hh
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 */
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{nullptr};
33
34 bool m_dolog;
35 bool m_in_transaction;
36 static int busyHandler(void*, int);
37 protected:
38 public:
39 //! Constructor.
40 SSQLite3( const std::string & database, const std::string & journalmode, bool creat=false);
41
42 //! Destructor.
43 ~SSQLite3();
44
45 std::unique_ptr<SSqlStatement> prepare(const string& query, int nparams) override;
46 void execute(const string& query) override;
47 void setLog(bool state) override;
48
49 void startTransaction() override;
50 void commit() override;
51 void rollback() override;
52
53 sqlite3 *db() { return this->m_pDB; };
54
55 bool inTransaction() { return m_in_transaction; };
56
57 //! Used to create an backend specific exception message.
58 SSqlException sPerrorException( const std::string & reason ) override;
59 };
60
61 #endif // SSQLITE3_HH
62