]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/ssqlite3.cc
rec: ensure correct service user on debian
[thirdparty/pdns.git] / pdns / ssqlite3.cc
index 62b223ceb2d2b76c1cd5cfe628460461b8205e04..eb7075388d1af4f7a925f61d8460b6bdc731455b 100644 (file)
@@ -49,13 +49,11 @@ int pdns_sqlite3_clear_bindings(sqlite3_stmt *pStmt){
 class SSQLite3Statement: public SSqlStatement
 {
 public:
-  SSQLite3Statement(SSQLite3 *db, bool dolog, const string& query) : d_prepared(false)
+  SSQLite3Statement(SSQLite3 *db, bool dolog, const string& query) :
+    d_query(query),
+    d_db(db),
+    d_dolog(dolog)
   {
-    this->d_query = query;
-    this->d_dolog = dolog;
-    d_stmt = NULL;
-    d_rc = 0;
-    d_db = db;
   }
 
   int name2idx(const string& name) {
@@ -148,12 +146,13 @@ public:
   const string& getQuery() { return d_query; };
 private:
   string d_query;
-  sqlite3_stmt* d_stmt;
-  SSQLite3* d_db;
-  int d_rc;
-  bool d_dolog;
-  bool d_prepared;
   DTime d_dtime;
+  sqlite3_stmt* d_stmt{nullptr};
+  SSQLite3* d_db{nullptr};
+  int d_rc{0};
+  bool d_dolog;
+  bool d_prepared{false};
+
   void prepareStatement() {
     const char *pTail;
 
@@ -175,13 +174,13 @@ private:
   void releaseStatement() {
     if (d_stmt)
       sqlite3_finalize(d_stmt);
-    d_stmt = NULL;
+    d_stmt = nullptr;
     d_prepared = false;
   }
 };
 
 // Constructor.
-SSQLite3::SSQLite3( const std::string & database, bool creat )
+SSQLite3::SSQLite3( const std::string & database, const std::string & journalmode, bool creat )
 {
   if (access( database.c_str(), F_OK ) == -1){
     if (!creat)
@@ -196,6 +195,9 @@ SSQLite3::SSQLite3( const std::string & database, bool creat )
   m_dolog = 0;
   m_in_transaction = false;
   sqlite3_busy_handler(m_pDB, busyHandler, 0);
+
+  if(journalmode.length())
+    execute("PRAGMA journal_mode="+journalmode);
 }
 
 void SSQLite3::setLog(bool state)