From 8439c4e3ca924026ef5e566e40773935e6f67c7f Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 23 Apr 2014 14:59:56 +0200 Subject: [PATCH] fix how we emit 'disabled' for 't' and 'f' SQL, plus implement feature to supress duplicate SOAs and turn it on by default --- pdns/zone2sql.cc | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/pdns/zone2sql.cc b/pdns/zone2sql.cc index 15d183210..87dd76d35 100644 --- a/pdns/zone2sql.cc +++ b/pdns/zone2sql.cc @@ -208,16 +208,16 @@ static void emitRecord(const string& zoneName, const string &qname, const string cout<<"insert into records (domain_id, name,type,content,ttl,prio,disabled) select id ,"<< sqlstr(toLower(stripDot(qname)))<<", "<< sqlstr(qtype)<<", "<< - sqlstr(stripDotContent(content))<<", "<filename, i->name, BP.getDirectory()); DNSResourceRecord rr; - while(zpt.get(rr)) + bool seenSOA=false; + while(zpt.get(rr)) { + if(filterDupSOA && seenSOA && rr.qtype.getCode() == QType::SOA) + continue; + if(rr.qtype.getCode() == QType::SOA) + seenSOA=true; emitRecord(i->name, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority); + } num_domainsdone++; } catch(std::exception &ae) { @@ -412,9 +422,13 @@ try startNewTransaction(); emitDomain(zonename); string comment; - + bool seenSOA=false; while(zpt.get(rr, &comment)) { - + if(filterDupSOA && seenSOA && rr.qtype.getCode() == QType::SOA) + continue; + if(rr.qtype.getCode() == QType::SOA) + seenSOA=true; + emitRecord(zonename, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority, comment); } num_domainsdone=1; -- 2.40.0