]> 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 c5f86f67c2d04fe1a5149b524c5985b9f090dcb5..eb7075388d1af4f7a925f61d8460b6bdc731455b 100644 (file)
@@ -50,12 +50,9 @@ class SSQLite3Statement: public SSqlStatement
 {
 public:
   SSQLite3Statement(SSQLite3 *db, bool dolog, const string& query) :
-    d_prepared(false),
     d_query(query),
-    d_dolog(dolog),
-    d_stmt(nullptr),
-    d_rc(0),
-    d_db(db)
+    d_db(db),
+    d_dolog(dolog)
   {
   }
 
@@ -149,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;
 
@@ -176,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)
@@ -197,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)