]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/ssqlite3.hh
Merge pull request #7757 from omoerbeek/rec-qname-min
[thirdparty/pdns.git] / pdns / ssqlite3.hh
CommitLineData
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
28class SSQLite3 : public SSql
29{
30private:
31 //! Pointer to the SQLite database instance.
eace2c24 32 sqlite3 *m_pDB{nullptr};
0b67a76d 33
a464c196 34 bool m_dolog;
0f310932 35 bool m_in_transaction;
cb8934ae 36 static int busyHandler(void*, int);
0b67a76d
BH
37protected:
38public:
39 //! Constructor.
367f9b40 40 SSQLite3( const std::string & database, const std::string & journalmode, 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;
346805ce
AT
46 void execute(const string& query) override;
47 void setLog(bool state) override;
0b67a76d 48
346805ce
AT
49 void startTransaction() override;
50 void commit() override;
51 void rollback() override;
0b67a76d 52
0f310932 53 sqlite3 *db() { return this->m_pDB; };
0b67a76d 54
0f310932 55 bool inTransaction() { return m_in_transaction; };
e237ea04 56
0b67a76d 57 //! Used to create an backend specific exception message.
346805ce 58 SSqlException sPerrorException( const std::string & reason ) override;
0b67a76d
BH
59};
60
61#endif // SSQLITE3_HH
62