]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Don't call virtual methods from SSQLite3 constructor 13538/head
authorFred Morcos <fred.morcos@open-xchange.com>
Tue, 28 Nov 2023 08:51:39 +0000 (09:51 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Tue, 28 Nov 2023 09:08:53 +0000 (10:08 +0100)
pdns/ssqlite3.cc
pdns/ssqlite3.hh

index 660c561b7810069696d7a92f352c01fd107f4f4b..2fecbba5bfa53169b92c4938647ea909d939c589 100644 (file)
@@ -290,24 +290,24 @@ SSQLite3::SSQLite3(const std::string& database, const std::string& journalmode,
 {
   if (access(database.c_str(), F_OK) == -1) {
     if (!creat) {
-      throw sPerrorException("SQLite database '" + database + "' does not exist yet");
+      throw SSqlException("SQLite database '" + database + "' does not exist yet");
     }
   }
   else {
     if (creat) {
-      throw sPerrorException("SQLite database '" + database + "' already exists");
+      throw SSqlException("SQLite database '" + database + "' already exists");
     }
   }
 
   if (sqlite3_open(database.c_str(), &m_pDB) != SQLITE_OK) {
-    throw sPerrorException("Could not connect to the SQLite database '" + database + "'");
+    throw SSqlException("Could not connect to the SQLite database '" + database + "'");
   }
   m_dolog = false;
   m_in_transaction = false;
   sqlite3_busy_handler(m_pDB, busyHandler, nullptr);
 
   if (journalmode.length() != 0) {
-    execute("PRAGMA journal_mode=" + journalmode);
+    executeImpl("PRAGMA journal_mode=" + journalmode);
   }
 }
 
@@ -338,7 +338,7 @@ std::unique_ptr<SSqlStatement> SSQLite3::prepare(const string& query, int nparam
   return std::make_unique<SSQLite3Statement>(this, m_dolog, query);
 }
 
-void SSQLite3::execute(const string& query)
+void SSQLite3::executeImpl(const string& query)
 {
   char* errmsg = nullptr;
   std::string errstr1;
@@ -364,6 +364,11 @@ void SSQLite3::execute(const string& query)
   }
 }
 
+void SSQLite3::execute(const string& query)
+{
+  executeImpl(query);
+}
+
 int SSQLite3::busyHandler([[maybe_unused]] void* userData, [[maybe_unused]] int invocationsSoFar)
 {
   Utility::usleep(1000);
index 29a1e10c9e99e02d4f5f8d311a46a83e48ff4f21..77b67171b5c0402cd14aefeac2d1804d66994fd1 100644 (file)
@@ -33,7 +33,8 @@ private:
   bool m_in_transaction;
   static int busyHandler(void*, int);
 
-protected:
+  void executeImpl(const string& query);
+
 public:
   //! Constructor.
   SSQLite3(const std::string& database, const std::string& journalmode, bool creat = false);