From 86bb67e1a324d6db98ff9cde4b7aaa8df565ea51 Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Wed, 15 Jun 2016 10:50:22 +0200 Subject: [PATCH] Revert "Use nullptr instead of empty DNSName" This reverts commit f22459fca7313a1ee234e41344b0973686279d7b. --- pdns/backends/gsql/gsqlbackend.cc | 56 ++++++++++++++----------------- pdns/backends/gsql/gsqlbackend.hh | 2 +- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index f63b2fb69..c2bc7376c 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -217,7 +217,7 @@ void GSQLBackend::setFresh(uint32_t domain_id) bool GSQLBackend::isMaster(const DNSName &domain, const string &ip) { - if (!isOurDomain(&domain)) return false; + if (!isOurDomain(domain)) return false; try { d_MasterOfDomainsZoneQuery_stmt-> @@ -250,7 +250,7 @@ bool GSQLBackend::isMaster(const DNSName &domain, const string &ip) bool GSQLBackend::setMaster(const DNSName &domain, const string &ip) { - if (!isOurDomain(&domain)) return false; + if (!isOurDomain(domain)) return false; try { d_UpdateMasterOfZoneQuery_stmt-> @@ -267,7 +267,7 @@ bool GSQLBackend::setMaster(const DNSName &domain, const string &ip) bool GSQLBackend::setKind(const DNSName &domain, const DomainInfo::DomainKind kind) { - if (!isOurDomain(&domain)) return false; + if (!isOurDomain(domain)) return false; try { d_UpdateKindOfZoneQuery_stmt-> @@ -284,7 +284,7 @@ bool GSQLBackend::setKind(const DNSName &domain, const DomainInfo::DomainKind ki bool GSQLBackend::setAccount(const DNSName &domain, const string &account) { - if (!isOurDomain(&domain)) return false; + if (!isOurDomain(domain)) return false; try { d_UpdateAccountOfZoneQuery_stmt-> @@ -301,7 +301,7 @@ bool GSQLBackend::setAccount(const DNSName &domain, const string &account) bool GSQLBackend::getDomainInfo(const DNSName &domain, DomainInfo &di) { - if (!isOurDomain(&domain)) return false; + if (!isOurDomain(domain)) return false; /* fill DomainInfo from database info: id,name,master IP(s),last_check,notified_serial,type,account */ @@ -444,7 +444,7 @@ bool GSQLBackend::updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName { if(!d_dnssecQueries) return false; - if (!isOurDomain(nullptr, domain_id)) return false; + if (!isOurDomain(DNSName(""), domain_id)) return false; if (!ordername.empty()) { if (qtype == QType::ANY) { @@ -508,7 +508,7 @@ bool GSQLBackend::updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName bool GSQLBackend::updateEmptyNonTerminals(uint32_t domain_id, const DNSName& zonename, set& insert, set& erase, bool remove) { - if (!isOurDomain(nullptr, domain_id)) return false; + if (!isOurDomain(DNSName(""), domain_id)) return false; if(remove) { try { @@ -567,7 +567,7 @@ bool GSQLBackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const string& qnam { if(!d_dnssecQueries) return false; - if (!isOurDomain(nullptr,id)) return false; + if (!isOurDomain(DNSName(""),id)) return false; // cerr<<"gsql before/after called for id="< @@ -687,7 +687,7 @@ bool GSQLBackend::activateDomainKey(const DNSName& name, unsigned int id) { if(!d_dnssecQueries) return false; - if (!isOurDomain(&name)) return false; + if (!isOurDomain(name)) return false; try { d_ActivateDomainKeyQuery_stmt-> @@ -706,7 +706,7 @@ bool GSQLBackend::deactivateDomainKey(const DNSName& name, unsigned int id) { if(!d_dnssecQueries) return false; - if (!isOurDomain(&name)) return false; + if (!isOurDomain(name)) return false; try { d_DeactivateDomainKeyQuery_stmt-> @@ -725,7 +725,7 @@ bool GSQLBackend::removeDomainKey(const DNSName& name, unsigned int id) { if(!d_dnssecQueries) return false; - if (!isOurDomain(&name)) return false; + if (!isOurDomain(name)) return false; try { d_RemoveDomainKeyQuery_stmt-> @@ -835,7 +835,7 @@ bool GSQLBackend::getDomainKeys(const DNSName& name, unsigned int kind, std::vec { if(!d_dnssecQueries) return false; - if (!isOurDomain(&name)) return false; + if (!isOurDomain(name)) return false; try { d_ListDomainKeysQuery_stmt-> @@ -878,7 +878,7 @@ void GSQLBackend::alsoNotifies(const DNSName &domain, set *ips) bool GSQLBackend::getAllDomainMetadata(const DNSName& name, std::map >& meta) { - if (!isOurDomain(&name)) return false; + if (!isOurDomain(name)) return false; try { d_GetAllDomainMetadataQuery_stmt-> @@ -937,7 +937,7 @@ bool GSQLBackend::setDomainMetadata(const DNSName& name, const std::string& kind { if(!d_dnssecQueries && isDnssecDomainMetadata(kind)) return false; - if (!isOurDomain(&name)) return false; + if (!isOurDomain(name)) return false; try { d_ClearDomainMetadataQuery_stmt-> @@ -1009,7 +1009,7 @@ void GSQLBackend::lookup(const QType &qtype,const DNSName &qname, DNSPacket *pkt bool GSQLBackend::list(const DNSName &target, int domain_id, bool include_disabled) { - if (!isOurDomain(&target, domain_id)) return false; + if (!isOurDomain(target, domain_id)) return false; DLOG(L<<"GSQLBackend constructing handle for list of domain id '"< *domains, bool include_disabl bool GSQLBackend::replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector& rrset) { - if (!isOurDomain(nullptr, domain_id)) return false; + if (!isOurDomain(DNSName(""), domain_id)) return false; try { if (qt != QType::ANY) { @@ -1329,7 +1329,7 @@ bool GSQLBackend::feedRecord(const DNSResourceRecord &r, string *ordername) bool GSQLBackend::feedEnts(int domain_id, map& nonterm) { - if (!isOurDomain(nullptr, domain_id)) return false; + if (!isOurDomain(DNSName(""), domain_id)) return false; for(const auto& nt: nonterm) { try { @@ -1352,7 +1352,7 @@ bool GSQLBackend::feedEnts3(int domain_id, const DNSName &domain, map=0 && !isOurDomain(nullptr, domain_id)) return false; + if (domain_id >=0 && !isOurDomain(DNSName(""), domain_id)) return false; try { d_db->startTransaction(); @@ -1425,7 +1425,7 @@ bool GSQLBackend::abortTransaction() bool GSQLBackend::calculateSOASerial(const DNSName& domain, const SOAData& sd, time_t& serial) { - if (!isOurDomain(nullptr, sd.domain_id)) return false; + if (!isOurDomain(DNSName(""), sd.domain_id)) return false; if (d_ZoneLastChangeQuery.empty()) { // query not set => fall back to default impl return DNSBackend::calculateSOASerial(domain, sd, serial); @@ -1454,7 +1454,7 @@ bool GSQLBackend::calculateSOASerial(const DNSName& domain, const SOAData& sd, t bool GSQLBackend::listComments(const uint32_t domain_id) { - if (!isOurDomain(nullptr, domain_id)) return false; + if (!isOurDomain(DNSName(""), domain_id)) return false; try { d_query_name = "list-comments-query"; @@ -1683,15 +1683,11 @@ void GSQLBackend::extractComment(const SSqlStatement::row_t& row, Comment& comme comment.content = row[5]; } -bool GSQLBackend::isOurDomain(const DNSName *zone, int domain_id) { +bool GSQLBackend::isOurDomain(const DNSName &zone, int domain_id) { try { d_IsOurDomainQuery_stmt-> - bind("id", domain_id); - if (zone) - d_IsOurDomainQuery_stmt->bind("zone", *zone); - else - d_IsOurDomainQuery_stmt->bindNull("zone"); - d_IsOurDomainQuery_stmt-> + bind("id", domain_id)-> + bind("zone", zone)-> execute()-> getResult(d_result)-> reset(); diff --git a/pdns/backends/gsql/gsqlbackend.hh b/pdns/backends/gsql/gsqlbackend.hh index add41f3e8..494d8345d 100644 --- a/pdns/backends/gsql/gsqlbackend.hh +++ b/pdns/backends/gsql/gsqlbackend.hh @@ -220,7 +220,7 @@ public: string directBackendCmd(const string &query); bool searchRecords(const string &pattern, int maxResults, vector& result); bool searchComments(const string &pattern, int maxResults, vector& result); - bool isOurDomain(const DNSName *zone, int domain_id=-1); + bool isOurDomain(const DNSName &zone, int domain_id=-1); protected: string pattern2SQLPattern(const string& pattern); void extractRecord(const SSqlStatement::row_t& row, DNSResourceRecord& rr); -- 2.40.0