]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
teach backends not to delete a zone if a negative zone-id is passed to startTransacti...
authorBert Hubert <bert.hubert@netherlabs.nl>
Tue, 25 Jan 2011 19:08:54 +0000 (19:08 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Tue, 25 Jan 2011 19:08:54 +0000 (19:08 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1906 d19b8d6e-7fed-0310-83ef-9ca221ded41b

modules/opendbxbackend/odbxbackend.cc
modules/pdnsbackend/pdnsbackend.cc
pdns/backends/bind/bindbackend2.cc

index 136c91bbfd53eaf05b39b0238e8f9d490b1d22fc..378d8946be07d092de250571b5d9cb19e07a99fa 100644 (file)
@@ -715,9 +715,11 @@ bool OdbxBackend::startTransaction( const string& domain, int zoneid )
                        return false;
                }
 
-               string stmt = getArg( "sql-zonedelete" );
-               stmtref = strbind( ":id", string( m_buffer, len ), stmt );
-               if( !execStmt( stmtref.c_str(), stmtref.size(), WRITE ) ) { return false; }
+                if(zoneid >= 0) {
+                       string stmt = getArg( "sql-zonedelete" );
+                       stmtref = strbind( ":id", string( m_buffer, len ), stmt );
+                       if( !execStmt( stmtref.c_str(), stmtref.size(), WRITE ) ) { return false; }
+                }
         }
         catch ( exception& e )
         {
index 4b9859feb505bf1a5bd18929ff97da90bacf8845..2f7bd6c4e45bc1c93ea2c0838318bc662c360e2f 100644 (file)
@@ -301,11 +301,13 @@ bool PdnsBackend::getDomainInfo(const string &domain, DomainInfo &di)
 
 bool PdnsBackend::startTransaction(const string &qname, int domain_id)
 {
+   
    ostringstream o;
    o << "delete from Records where ZoneId=" << domain_id;
 
    this->Execute("begin");
-   this->Execute(o.str());
+   if(domain_id >= 0)
+     this->Execute(o.str());
    
    d_axfrcount = 0;
    
index 8fd53a23feb0ed11057057d4635382372e211fdb..f3018f1c5579b0a6abc22e38a70bb98929407d76 100644 (file)
@@ -155,6 +155,11 @@ shared_ptr<Bind2Backend::State> Bind2Backend::getState()
 
 bool Bind2Backend::startTransaction(const string &qname, int id)
 {
+  if(id < 0) {
+    d_transaction_tmpname.clear();
+    d_transaction_id=id;
+    return true;
+  }
   shared_ptr<State> state = getState(); 
 
   const BB2DomainInfo &bbd=state->id_zone_map[d_transaction_id=id];
@@ -176,6 +181,8 @@ bool Bind2Backend::startTransaction(const string &qname, int id)
 
 bool Bind2Backend::commitTransaction()
 {
+  if(d_transaction_id < 0)
+    return true;
   delete d_of;
   d_of=0;
   shared_ptr<State> state = getState(); 
@@ -193,7 +200,7 @@ bool Bind2Backend::commitTransaction()
 
 bool Bind2Backend::abortTransaction()
 {
-  if(d_transaction_id) {
+  if(d_transaction_id >= 0) {
     delete d_of;
     d_of=0;
     unlink(d_transaction_tmpname.c_str());