]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Deprecate the insert-slave-query
authorPieter Lexis <pieter.lexis@powerdns.com>
Wed, 10 Feb 2016 14:35:10 +0000 (15:35 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Wed, 24 Feb 2016 14:51:57 +0000 (15:51 +0100)
docs/markdown/authoritative/backend-generic-sql.md
modules/gmysqlbackend/gmysqlbackend.cc
modules/godbcbackend/godbcbackend.cc
modules/goraclebackend/goraclebackend.cc
modules/gpgsqlbackend/gpgsqlbackend.cc
modules/gsqlite3backend/gsqlite3backend.cc
pdns/backends/gsql/gsqlbackend.cc
pdns/backends/gsql/gsqlbackend.hh

index 704b083319c3b9153003a23205ff3168b844a117..5cd920d774d8d36a98c8354bf7325a6fc220dc99 100644 (file)
@@ -197,7 +197,7 @@ if you wish to calculate ordername and auth without using pdns-rectify.
 
 - `is-our-domain-query`: Checks if the domain (either id or name) is in the 'domains' table. This query is run before any other (possibly heavy) query.
 
-- `insert-zone-query`: Add a new NATIVE domain.
+- `insert-zone-query`: Add a new domain. This query also requires the type, masters and account fields
 - `update-kind-query`: Called to update the type of domain.
 - `delete-zone-query` Called to delete all records of a zone. Used before an incoming AXFR.
 - `delete-domain-query`: Called to delete a domain from the domains-table.
@@ -234,7 +234,6 @@ Most installations will have zero need to change the following queries.
 
 ### On slaves
 - `info-all-slaves-query`: Called to retrieve all slave domains.
-- `insert-slave-query`: Called to add a domain as slave after a supermaster notification.
 - `master-zone-query`: Called to determine the master of a zone.
 - `update-lastcheck-query`: Called to update the last time a slave domain was successfully checked for freshness.
 - `update-master-query`: Called to update the master address of a domain.
index 6b0e7c033e0c10833161b76abad6a3a14281e5ef..1c80d0d4ebcfb31ffaed2fc5e525d93cc1644314 100644 (file)
@@ -74,8 +74,7 @@ public:
     declare(suffix,"supermaster-query","", "select account from supermasters where ip=? and nameserver=?");
     declare(suffix,"supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=? and account=?");
 
-    declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',?)");
-    declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',?,?,?)");
+    declare(suffix,"insert-zone-query","", "insert into domains (type,name,master,account) values(?,?,?,?)");
 
     declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (?,?,?,?,?,?,?,?,?)");
     declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,?,0,?,?,?)");
index 9be9e7c64c837eb7e60bf118bb3383838fb535d3..e0dcf24b1b0058f6f7dc2c342aec74fecb4dba1c 100644 (file)
@@ -72,8 +72,7 @@ public:
     declare(suffix,"supermaster-query","", "select account from supermasters where ip=? and nameserver=?");
     declare(suffix,"supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=? and account=?");
 
-    declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',?)");
-    declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',?,?,?)");
+    declare(suffix,"insert-zone-query","", "insert into domains (type,name,master,account) values(?,?,?,?)");
 
     declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (?,?,?,?,?,?,?,convert(varbinary(255),?),?)");
     declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,?,0,?,convert(varbinary(255),?),?)");
index a52908940bdbed9a0c91c2f509d32d76bcc02f32..c79748056e0e6b75914165ec697870203bbd6e56 100644 (file)
@@ -88,8 +88,7 @@ public:
     declare(suffix, "info-all-slaves-query", "","select id,name,master,last_check from domains where type='SLAVE'");
     declare(suffix, "supermaster-query", "", "select account from supermasters where ip=:ip and nameserver=:nameserver");
     declare(suffix, "supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=:nameserver and account=:account");
-    declare(suffix, "insert-zone-query", "", "insert into domains (id,type,name) values(domains_id_sequence.nextval,'NATIVE',:domain)");
-    declare(suffix, "insert-slave-query", "", "insert into domains (id,type,name,master,account) values(domains_id_sequence.nextval,'SLAVE',:domain,:masters,:account)");
+    declare(suffix, "insert-zone-query", "", "insert into domains (id,type,name,master,account) values(domains_id_sequence.nextval,:type,:domain,:masters,:account)");
     declare(suffix, "insert-record-query", "", "insert into records (id,content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (records_id_sequence.nextval,:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:ordername || ' ',:auth)");
     declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (id,type,domain_id,disabled,name,ordername,auth) values (records_id_sequence.nextval,null,:domain_id,0,:qname,:ordername,:auth)");
 
index f5b97391e4cba95d8ea3375a9809f5918a86d07d..efade6beaebc9b5186c9c361ee36ac5848f6ccda 100644 (file)
@@ -69,8 +69,7 @@ public:
     declare(suffix,"supermaster-query","", "select account from supermasters where ip=$1 and nameserver=$2");
     declare(suffix,"supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=$1 and account=$2");
 
-    declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',$1)");
-    declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',$1,$2,$3)");
+    declare(suffix,"insert-zone-query","", "insert into domains (type,name,master,account) values($1,$2,$3,$4)");
 
     declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values ($1,$2,$3,$4,$5,$6,$7,$8,$9)");
     declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,$1,false,$2,$3,$4)");
index 9952acfaea3c90e6e1b8404e36ae258732068e6c..fe74686cb4b27a5e1fa179ecef86805019f7b06a 100644 (file)
@@ -85,8 +85,7 @@ public:
     declare(suffix, "supermaster-query", "", "select account from supermasters where ip=:ip and nameserver=:nameserver");
     declare(suffix, "supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=:nameserver and account=:account");
 
-    declare(suffix, "insert-zone-query", "", "insert into domains (type,name) values('NATIVE',:domain)");
-    declare(suffix, "insert-slave-query", "", "insert into domains (type,name,master,account) values('SLAVE',:domain,:masters,:account)");
+    declare(suffix, "insert-zone-query", "", "insert into domains (type,name,master,account) values(:type, :domain, :masters, :account)");
 
     declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:ordername,:auth)");
     declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,:domain_id,0,:qname,:ordername,:auth)");
index 70f5e3eee688d7b8921b383ab150e3feeac53962..c607b17114aebba221bfa59ad4e12d2b68a40a2a 100644 (file)
@@ -69,7 +69,6 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix)
   d_SuperMasterInfoQuery=getArg("supermaster-query");
   d_GetSuperMasterIPs=getArg("supermaster-name-to-ips");
   d_InsertZoneQuery=getArg("insert-zone-query");
-  d_InsertSlaveZoneQuery=getArg("insert-slave-query");
   d_InsertRecordQuery=getArg("insert-record-query");
   d_UpdateMasterOfZoneQuery=getArg("update-master-query");
   d_UpdateKindOfZoneQuery=getArg("update-kind-query");
@@ -140,7 +139,6 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix)
   d_SuperMasterInfoQuery_stmt = NULL;
   d_GetSuperMasterIPs_stmt = NULL;
   d_InsertZoneQuery_stmt = NULL;
-  d_InsertSlaveZoneQuery_stmt = NULL;
   d_InsertRecordQuery_stmt = NULL;
   d_InsertEmptyNonTerminalOrderQuery_stmt = NULL;
   d_UpdateMasterOfZoneQuery_stmt = NULL;
@@ -1108,11 +1106,14 @@ bool GSQLBackend::superMasterBackend(const string &ip, const DNSName &domain, co
   return false;
 }
 
-bool GSQLBackend::createDomain(const DNSName &domain)
+bool GSQLBackend::createDomain(const DNSName &domain, const string &type, const string &masters, const string &account)
 {
   try {
     d_InsertZoneQuery_stmt->
+      bind("type", type)->
       bind("domain", domain)->
+      bind("masters", masters)->
+      bind("account", account)->
       execute()->
       reset();
   }
@@ -1146,12 +1147,7 @@ bool GSQLBackend::createSlaveDomain(const string &ip, const DNSName &domain, con
         masters = boost::join(tmp, ", ");
       }
     }
-    d_InsertSlaveZoneQuery_stmt->
-      bind("domain", domain)->
-      bind("masters", masters)->
-      bind("account", account)->
-      execute()->
-      reset();
+    createDomain(domain, "SLAVE", masters, account);
   }
   catch(SSqlException &e) {
     throw DBException("Database error trying to insert new slave domain '"+domain.toString()+"': "+ e.txtReason());
index ae713201a0ac2aaf03619ddb63964a51ac7ed0e4..add41f3e8bf02ac3e321b31e38e4d8fafb8e3cdd 100644 (file)
@@ -42,8 +42,7 @@ public:
       d_InfoOfAllSlaveDomainsQuery_stmt = d_db->prepare(d_InfoOfAllSlaveDomainsQuery, 0);
       d_SuperMasterInfoQuery_stmt = d_db->prepare(d_SuperMasterInfoQuery, 2);
       d_GetSuperMasterIPs_stmt = d_db->prepare(d_GetSuperMasterIPs, 2);
-      d_InsertZoneQuery_stmt = d_db->prepare(d_InsertZoneQuery, 1);
-      d_InsertSlaveZoneQuery_stmt = d_db->prepare(d_InsertSlaveZoneQuery, 3);
+      d_InsertZoneQuery_stmt = d_db->prepare(d_InsertZoneQuery, 4);
       d_InsertRecordQuery_stmt = d_db->prepare(d_InsertRecordQuery, 9);
       d_InsertEmptyNonTerminalOrderQuery_stmt = d_db->prepare(d_InsertEmptyNonTerminalOrderQuery, 4);
       d_UpdateMasterOfZoneQuery_stmt = d_db->prepare(d_UpdateMasterOfZoneQuery, 2);
@@ -111,7 +110,6 @@ public:
     release(&d_SuperMasterInfoQuery_stmt);
     release(&d_GetSuperMasterIPs_stmt);
     release(&d_InsertZoneQuery_stmt);
-    release(&d_InsertSlaveZoneQuery_stmt);
     release(&d_InsertRecordQuery_stmt);
     release(&d_InsertEmptyNonTerminalOrderQuery_stmt);
     release(&d_UpdateMasterOfZoneQuery_stmt);
@@ -172,7 +170,10 @@ public:
   bool feedRecord(const DNSResourceRecord &r, string *ordername=0);
   bool feedEnts(int domain_id, map<DNSName,bool>& nonterm);
   bool feedEnts3(int domain_id, const DNSName &domain, map<DNSName,bool> &nonterm, const NSEC3PARAMRecordContent& ns3prc, bool narrow);
-  bool createDomain(const DNSName &domain);
+  bool createDomain(const DNSName &domain, const string &type, const string &masters, const string &account);
+  bool createDomain(const DNSName &domain) {
+    return createDomain(domain, "NATIVE", "", "");
+  };
   bool createSlaveDomain(const string &ip, const DNSName &domain, const string &nameserver, const string &account);
   bool deleteDomain(const DNSName &domain);
   bool superMasterBackend(const string &ip, const DNSName &domain, const vector<DNSResourceRecord>&nsset, string *nameserver, string *account, DNSBackend **db);
@@ -248,7 +249,6 @@ private:
   string d_GetSuperMasterIPs;
 
   string d_InsertZoneQuery;
-  string d_InsertSlaveZoneQuery;
   string d_InsertRecordQuery;
   string d_InsertEmptyNonTerminalOrderQuery;
   string d_UpdateMasterOfZoneQuery;
@@ -320,7 +320,6 @@ private:
   SSqlStatement* d_SuperMasterInfoQuery_stmt;
   SSqlStatement* d_GetSuperMasterIPs_stmt;
   SSqlStatement* d_InsertZoneQuery_stmt;
-  SSqlStatement* d_InsertSlaveZoneQuery_stmt;
   SSqlStatement* d_InsertRecordQuery_stmt;
   SSqlStatement* d_InsertEmptyNonTerminalOrderQuery_stmt;
   SSqlStatement* d_UpdateMasterOfZoneQuery_stmt;