]> granicus.if.org Git - pdns/commitdiff
disable sqlite3 foreign keys by default
authorKees Monshouwer <mind04@monshouwer.org>
Mon, 22 Dec 2014 09:42:30 +0000 (10:42 +0100)
committermind04 <mind04@monshouwer.org>
Mon, 22 Dec 2014 10:30:27 +0000 (11:30 +0100)
modules/gsqlite3backend/gsqlite3backend.cc
pdns/docs/markdown/authoritative/backend-gsqlite.md

index aa41b2911a3a8ecc3efb40a76a799e221b18ccb2..7e885c725ef3539a44378b56260f906a8c3ef951 100644 (file)
 // Connects to the database.
 gSQLite3Backend::gSQLite3Backend( const std::string & mode, const std::string & suffix ) : GSQLBackend( mode, suffix )
 {
-  try 
+  try
   {
-    SSQLite3 *ptr = new SSQLite3( getArg( "database" ));    
+    SSQLite3 *ptr = new SSQLite3( getArg( "database" ));
     setDB( ptr);
     if(!getArg("pragma-synchronous").empty()) {
       SSQLite3::result_t res;
       ptr->doQuery("PRAGMA synchronous="+getArg("pragma-synchronous"), res);
     }
-    SSQLite3::result_t res;
-    ptr->doQuery("PRAGMA foreign_keys = 1", res);
-  }  
-  catch( SSqlException & e ) 
+    if(mustDo("pragma-foreign-keys")) {
+      SSQLite3::result_t res;
+      ptr->doQuery("PRAGMA foreign_keys = ON", res);
+    }
+  }
+  catch( SSqlException & e )
   {
     L << Logger::Error << mode << ": connection failed: " << e.txtReason() << std::endl;
     throw PDNSException( "Unable to launch " + mode + " connection: " + e.txtReason());
@@ -59,6 +61,7 @@ public:
   {
     declare( suffix, "database", "Filename of the SQLite3 database", "powerdns.sqlite" );
     declare( suffix, "pragma-synchronous", "Set this to 0 for blazing speed", "" );
+    declare( suffix, "pragma-foreign-keys", "Enable foreign key constraints", "no" );
 
     declare(suffix, "dnssec", "Enable DNSSEC processing","no");
 
index 13caf4c1e32c916d3d8bfb39b41328c46ff05dcf..17cd7713df27e0ec3627c69e64be6fdcfa989add 100644 (file)
@@ -39,6 +39,21 @@ After you have created the database you probably want to fill it with data. If y
 
 To communicate with a SQLite database, use either the 'sqlite' or 'sqlite3' program, and feed it SQL.
 
+## Configuration Parameters
+These are the configuration file parameters that are available for the gsqlite3 backend.
+
+### `(gsqlite3)-database`
+Filename of the SQLite3 database.
+
+### `(gsqlite3)-pragma-synchronous`
+Set this to 0 for blazing speed.
+
+### `(gsqlite3)-pragma-foreign-keys`
+Enable foreign key constraints.
+
+### `(gsqlite3)-dnssec`
+Enable DNSSEC processing.
+
 ## Using the SQLite backend
 The last thing you need to do is telling PowerDNS to use the SQLite backend.