* Master: Yes
* Slave: Yes
* Superslave: Yes
-* Autoserial: Yes
+* Autoserial: No
* Case: All lower
* DNSSEC: Yes (set ``gmysql-dnssec``)
* Disabled data: Yes
* Master: Yes
* Slave: Yes
* Superslave: Yes
-* Autoserial: Yes
+* Autoserial: No
* Case: All lower
* DNSSEC: Yes
* Disabled data: Yes
* Master: Yes
* Slave: Yes
* Superslave: Yes
-* Autoserial: Yes
+* Autoserial: No
* Case: All lower
* DNSSEC: Yes (set ``goracle-dnssec``)
* Disabled data: Yes
* Master: Yes
* Slave: Yes
* Superslave: Yes
-* Autoserial: Yes
+* Autoserial: No
* Case: All lower
* DNSSEC: Yes (set ``gpgsql-dnssec``)
* Disabled data: Yes
domain to have a serial of 0; this implies that a slaved domain will not
stay disabled.
-.. _autoserial:
-
-Autoserial
-^^^^^^^^^^
-
-The autoserial functionality makes PowerDNS generate the SOA serial when
-the SOA serial set to ``0`` in the database. The serial in SOA responses
-is set to what's provided by ``zone-lastchange-query``. By default, this
-is the highest value of the ``change_date`` field in the "records"
-table).
-
.. _generic-sql-handling-dnssec-signed-zones:
Handling DNSSEC signed zones
which the server is master.
- ``update-serial-query`` Called to update the last notified serial of
a master domain.
-- ``zone-lastchange-query``: Called to determine the last change to a
- zone, used for autoserial.
On slaves
~~~~~~~~~
* Master: Yes
* Slave: Yes
* Superslave: Yes
-* Autoserial: Yes
+* Autoserial: No
* DNSSEC: Yes
* Comments: No
* Module name: oracle
except that if this includes FQDNs, they should be specified without a
trailing dot.
-last\_change
-^^^^^^^^^^^^
-
-The unix timestamp of the last change to this record. Used only for the
-deprecated autoserial feature. You can omit this unless you want to use
-that feature.
-
auth
^^^^
- zone\_id: The numerical identifier of the zone the record belongs to.
A record can belong to two zones (delegations/glue), in which case it
may be returned twice.
-- last\_change: The unix timestamp of the last time this record was
- changed. Can safely be set as a constant 0, unless you use the
- autoserial feature.
- auth: 1 or 0 depending on the zone membership (authoritative or not).
Record sets (records for the same name of the same type) must appear
ALTER TABLE domains MODIFY notified_serial INT UNSIGNED DEFAULT NULL;
+
+ALTER TABLE records DROP COLUMN change_date;
dnssec-3.x_to_3.4.0_schema.mysql.sql \
nodnssec-3.x_to_3.4.0_schema.mysql.sql \
3.4.0_to_4.1.0_schema.mysql.sql \
- 4.1.0_to_4.1.1_schema.mysql.sql \
+ 4.1.0_to_5.0.0_schema.mysql.sql \
schema.mysql.sql
libgmysqlbackend_la_SOURCES = \
declare(suffix,"insert-zone-query","", "insert into domains (type,name,master,account,last_check,notified_serial) values(?,?,?,?,NULL,NULL)");
- declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth,change_date) values (?,?,?,?,?,?,?,?,?,NULL)");
- declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth,change_date,content,ttl,prio) values (null,?,0,?,?,?,NULL,NULL,NULL,NULL)");
+ 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,content,ttl,prio) values (null,?,0,?,?,?,NULL,NULL,NULL)");
declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select ordername from records where domain_id=? and disabled=0 and ordername is not null order by 1 asc limit 1");
declare(suffix, "get-order-before-query", "DNSSEC Ordering Query, before", "select ordername, name from records where ordername <= ? and domain_id=? and disabled=0 and ordername is not null order by 1 desc limit 1");
declare(suffix,"update-account-query","", "update domains set account=? where name=?");
declare(suffix,"update-serial-query","", "update domains set notified_serial=? where id=?");
declare(suffix,"update-lastcheck-query","", "update domains set last_check=? where id=?");
- declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=?");
declare(suffix,"info-all-master-query","", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'");
declare(suffix,"delete-domain-query","", "delete from domains where name=?");
declare(suffix,"delete-zone-query","", "delete from records where domain_id=?");
content VARCHAR(64000) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
- change_date INT DEFAULT NULL,
disabled TINYINT(1) DEFAULT 0,
ordername VARCHAR(255) BINARY DEFAULT NULL,
auth TINYINT(1) DEFAULT 1,
--- /dev/null
+ALTER TABLE records DROP COLUMN change_date;
EXTRA_DIST=OBJECTFILES OBJECTLIBS
-dist_doc_DATA=schema.mssql.sql
+dist_doc_DATA=schema.mssql.sql \
+ 4.0.0_to_5.0.0_schema.mssql.sql
libgodbcbackend_la_SOURCES=godbcbackend.cc godbcbackend.hh \
sodbc.hh sodbc.cc
declare(suffix,"insert-zone-query","", "insert into domains (type,name,master,account,last_check,notified_serial) values(?,?,?,?,null,null)");
- declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth,change_date) values (?,?,?,?,?,?,?,convert(varbinary(255),?),?,null)");
- declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth,ttl,prio,change_date,content) values (null,?,0,?,convert(varbinary(255),?),?,null,null,null,null)");
+ 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,ttl,prio,content) values (null,?,0,?,convert(varbinary(255),?),?,null,null,null)");
declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select top 1 convert(varchar(255), ordername) from records where domain_id=? and disabled=0 and ordername is not null order by 1 asc");
declare(suffix, "get-order-before-query", "DNSSEC Ordering Query, before", "select top 1 convert(varchar(255), ordername), name from records where ordername <= convert(varbinary(255),?) and domain_id=? and disabled=0 and ordername is not null order by 1 desc");
declare(suffix,"update-account-query","", "update domains set account=? where name=?");
declare(suffix,"update-serial-query","", "update domains set notified_serial=? where id=?");
declare(suffix,"update-lastcheck-query","", "update domains set last_check=? where id=?");
- declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=?");
declare(suffix,"info-all-master-query","", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'");
declare(suffix,"delete-domain-query","", "delete from domains where name=?");
declare(suffix,"delete-zone-query","", "delete from records where domain_id=?");
content VARCHAR(MAX) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
- change_date INT DEFAULT NULL,
disabled BIT DEFAULT 0,
ordername VARBINARY(255) DEFAULT NULL,
auth BIT DEFAULT 1,
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,master,account,last_check_notified_serial) values(domains_id_sequence.nextval,:type,:domain,:masters,:account, null, null)");
- declare(suffix, "insert-record-query", "", "insert into records (id,content,ttl,prio,type,domain_id,disabled,name,ordername,auth,change_date) values (records_id_sequence.nextval,:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:ordername || ' ',:auth, null)");
- 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,ttl,prio,change_date,content) values (records_id_sequence.nextval,null,:domain_id,0,:qname,:ordername,:auth,null,null,null,null)");
+ 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,ttl,prio,content) values (records_id_sequence.nextval,null,:domain_id,0,:qname,:ordername,:auth,null,null,null)");
declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select * FROM (select trim(ordername) from records where disabled=0 and domain_id=:domain_id and ordername is not null order by ordername asc) where rownum=1");
declare(suffix, "get-order-before-query", "DNSSEC Ordering Query, before", "select * FROM (select trim(ordername), name from records where disabled=0 and ordername <= :ordername || ' ' and domain_id=:domain_id and ordername is not null order by ordername desc) where rownum=1");
declare(suffix, "update-account-query", "", "update domains set account=:account where name=:domain");
declare(suffix, "update-serial-query", "", "update domains set notified_serial=:serial where id=:domain_id");
declare(suffix, "update-lastcheck-query", "", "update domains set last_check=:last_check where id=:domain_id");
- declare(suffix, "zone-lastchange-query", "", "select max(change_date) from records where domain_id=:domain_id");
declare(suffix, "info-all-master-query", "", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'");
declare(suffix, "delete-domain-query","", "delete from domains where name=:domain");
declare(suffix, "delete-zone-query", "", "delete from records where domain_id=:domain_id");
content VARCHAR2(4000) DEFAULT NULL,
ttl INTEGER DEFAULT NULL,
prio INTEGER DEFAULT NULL,
- change_date INTEGER DEFAULT NULL,
disabled NUMBER(1,0) DEFAULT 0 NOT NULL,
ordername VARCHAR2(255) DEFAULT NULL,
auth NUMBER(1,0) DEFAULT 1 NOT NULL,
--- /dev/null
+ALTER TABLE records DROP COLUMN change_date;
schema.pgsql.sql \
nodnssec-3.x_to_3.4.0_schema.pgsql.sql \
dnssec-3.x_to_3.4.0_schema.pgsql.sql \
- 3.4.0_to_4.1.0_schema.pgsql.sql
+ 3.4.0_to_4.1.0_schema.pgsql.sql \
+ 4.1.0_to_5.0.0_schema.pgsql.sql
libgpgsqlbackend_la_SOURCES = \
gpgsqlbackend.cc gpgsqlbackend.hh \
declare(suffix,"insert-zone-query","", "insert into domains (type,name,master,account,last_check, notified_serial) values($1,$2,$3,$4,null,null)");
- declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth,change_date) values ($1,$2,$3,$4,$5,$6,$7,$8,$9,null)");
- declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth,ttl,prio,change_date,content) values (null,$1,false,$2,$3,$4,null,null,null,null)");
+ 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,ttl,prio,content) values (null,$1,false,$2,$3,$4,null,null,null)");
declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, last", "select ordername from records where disabled=false and domain_id=$1 and ordername is not null order by 1 using ~<~ limit 1");
declare(suffix, "get-order-before-query", "DNSSEC Ordering Query, before", "select ordername, name from records where disabled=false and ordername ~<=~ $1 and domain_id=$2 and ordername is not null order by 1 using ~>~ limit 1");
declare(suffix,"update-account-query","", "update domains set account=$1 where name=$2");
declare(suffix,"update-serial-query","", "update domains set notified_serial=$1 where id=$2");
declare(suffix,"update-lastcheck-query","", "update domains set last_check=$1 where id=$2");
- declare(suffix,"zone-lastchange-query", "", "select max(change_date) from records where domain_id=$1");
declare(suffix,"info-all-master-query","", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'");
declare(suffix,"delete-domain-query","", "delete from domains where name=$1");
declare(suffix,"delete-zone-query","", "delete from records where domain_id=$1");
content VARCHAR(65535) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
- change_date INT DEFAULT NULL,
disabled BOOL DEFAULT 'f',
ordername VARCHAR(255),
auth BOOL DEFAULT 't',
--- /dev/null
+BEGIN TRANSACTION;
+ CREATE TEMPORARY TABLE records_backup (
+ id INTEGER PRIMARY KEY,
+ domain_id INTEGER DEFAULT NULL,
+ name VARCHAR(255) DEFAULT NULL,
+ type VARCHAR(10) DEFAULT NULL,
+ content VARCHAR(65535) DEFAULT NULL,
+ ttl INTEGER DEFAULT NULL,
+ prio INTEGER DEFAULT NULL,
+ disabled BOOLEAN DEFAULT 0,
+ ordername VARCHAR(255),
+ auth BOOL DEFAULT 1
+ );
+
+ INSERT INTO records_backup SELECT id,domain_id,name,type,content,ttl,prio,disabled,ordername,auth FROM records;
+ DROP TABLE records;
+
+ CREATE TABLE records (
+ id INTEGER PRIMARY KEY,
+ domain_id INTEGER DEFAULT NULL,
+ name VARCHAR(255) DEFAULT NULL,
+ type VARCHAR(10) DEFAULT NULL,
+ content VARCHAR(65535) DEFAULT NULL,
+ ttl INTEGER DEFAULT NULL,
+ prio INTEGER DEFAULT NULL,
+ disabled BOOLEAN DEFAULT 0,
+ ordername VARCHAR(255),
+ auth BOOL DEFAULT 1,
+ FOREIGN KEY(domain_id) REFERENCES domains(id) ON DELETE CASCADE ON UPDATE CASCADE
+ );
+
+ CREATE INDEX rec_name_index ON records(name);
+ CREATE INDEX nametype_index ON records(name,type);
+ CREATE INDEX domain_id ON records(domain_id);
+ CREATE INDEX orderindex ON records(ordername);
+
+ INSERT INTO records SELECT id,domain_id,name,type,content,ttl,prio,disabled,ordername,auth FROM records_backup;
+ DROP TABLE records_backup;
+COMMIT;
dist_doc_DATA = \
dnssec-3.x_to_3.4.0_schema.sqlite3.sql \
nodnssec-3.x_to_3.4.0_schema.sqlite3.sql \
+ 3.4.0_to_4.0.0_schema.sqlite3.sql \
+ 4.0.0_to_5.0.0_schema.sqlite3.sql \
schema.sqlite3.sql
libgsqlite3backend_la_SOURCES = gsqlite3backend.cc gsqlite3backend.hh
declare(suffix, "insert-zone-query", "", "insert into domains (type,name,master,account,last_check,notified_serial) values(:type, :domain, :masters, :account, null, null)");
- declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth,change_date) values (:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:ordername,:auth,null)");
- declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth,ttl,prio,change_date,content) values (null,:domain_id,0,:qname,:ordername,:auth,null,null,null,null)");
+ 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,ttl,prio,content) values (null,:domain_id,0,:qname,:ordername,:auth,null,null,null)");
declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select ordername from records where disabled=0 and domain_id=:domain_id and ordername is not null order by 1 asc limit 1");
declare(suffix, "get-order-before-query", "DNSSEC Ordering Query, before", "select ordername, name from records where disabled=0 and ordername <= :ordername and domain_id=:domain_id and ordername is not null order by 1 desc limit 1");
declare(suffix, "update-account-query","", "update domains set account=:account where name=:domain");
declare(suffix, "update-serial-query", "", "update domains set notified_serial=:serial where id=:domain_id");
declare(suffix, "update-lastcheck-query", "", "update domains set last_check=:last_check where id=:domain_id");
- declare(suffix, "zone-lastchange-query", "", "select max(change_date) from records where domain_id=:domain_id");
declare(suffix, "info-all-master-query", "", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'");
declare(suffix, "delete-domain-query","", "delete from domains where name=:domain");
declare(suffix, "delete-zone-query", "", "delete from records where domain_id=:domain_id");
content VARCHAR(65535) DEFAULT NULL,
ttl INTEGER DEFAULT NULL,
prio INTEGER DEFAULT NULL,
- change_date INTEGER DEFAULT NULL,
disabled BOOLEAN DEFAULT 0,
ordername VARCHAR(255),
auth BOOL DEFAULT 1,
void lookup(const QType &qtype, const DNSName &qname, DNSPacket *p, int domain_id) override;
bool get(DNSResourceRecord &rr) override;
//! fills the soadata struct with the SOA details. Returns false if there is no SOA.
- bool getSOA(const DNSName &name, SOAData &soadata, bool unmodifiedSerial) override;
+ bool getSOA(const DNSName &name, SOAData &soadata) override;
// MASTER BACKEND
return !rr.content.empty();
}
-bool LUABackend::getSOA(const DNSName &name, SOAData &soadata, bool unmodifiedSerial) {
+bool LUABackend::getSOA(const DNSName &name, SOAData &soadata) {
if (logging)
g_log << Logger::Info << backend_name << "(getsoa) BEGIN" << endl;
return true;
}
-bool MyDNSBackend::getSOA(const DNSName& name, SOAData& soadata, bool unmodifiedSerial) {
+bool MyDNSBackend::getSOA(const DNSName& name, SOAData& soadata) {
string query;
SSqlStatement::row_t rrow;
void lookup(const QType &, const DNSName &qdomain, DNSPacket *p=0, int zoneId=-1) override;
bool list(const DNSName &target, int domain_id, bool include_disabled=false) override;
bool get(DNSResourceRecord &r) override;
- bool getSOA(const DNSName& name, SOAData& soadata, bool unmodifiedSerial) override;
+ bool getSOA(const DNSName& name, SOAData& soadata) override;
void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false) override;
private:
-bool OdbxBackend::getSOA( const DNSName& domain, SOAData& sd, bool unmodifiedSerial)
+bool OdbxBackend::getSOA( const DNSName& domain, SOAData& sd )
{
const char* tmp;
sd.ttl = strtoul( tmp, NULL, 10 );
}
- if( !unmodifiedSerial && sd.serial == 0 && ( tmp = odbx_field_value( m_result, 1 ) ) != NULL )
+ if( sd.serial == 0 && ( tmp = odbx_field_value( m_result, 1 ) ) != NULL )
{
sd.serial = strtol( tmp, NULL, 10 );
}
~OdbxBackend();
void lookup( const QType& qtype, const DNSName& qdomain, DNSPacket* p = 0, int zoneid = -1 ) override;
- bool getSOA( const DNSName& domain, SOAData& sd, bool unmodifiedSerial ) override;
+ bool getSOA( const DNSName& domain, SOAData& sd ) override;
bool list( const DNSName& target, int domain_id, bool include_disabled=false ) override;
bool get( DNSResourceRecord& rr ) override;
static const char *basicQueryKey = "PDNS_Basic_Query";
static const char *basicQueryDefaultAuthSQL =
- "SELECT fqdn, ttl, type, content, zone_id, last_change, auth "
+ "SELECT fqdn, ttl, type, content, zone_id, auth "
"FROM Records "
"WHERE type = :type AND fqdn = lower(:name)";
-static const char *basicQueryDefaultSQL = "SELECT fqdn, ttl, type, content, zone_id, last_change "
+static const char *basicQueryDefaultSQL = "SELECT fqdn, ttl, type, content, zone_id, "
"FROM Records "
"WHERE type = :type AND fqdn = lower(:name)";
static const char *basicIdQueryKey = "PDNS_Basic_Id_Query";
static const char *basicIdQueryDefaultAuthSQL =
- "SELECT fqdn, ttl, type, content, zone_id, last_change, auth "
+ "SELECT fqdn, ttl, type, content, zone_id, auth "
"FROM Records "
"WHERE type = :type AND fqdn = lower(:name) AND zone_id = :zoneid";
static const char *basicIdQueryDefaultSQL =
- "SELECT fqdn, ttl, type, content, zone_id, last_change "
+ "SELECT fqdn, ttl, type, content, zone_id, "
"FROM Records "
"WHERE type = :type AND fqdn = lower(:name) AND zone_id = :zoneid";
static const char *anyQueryKey = "PDNS_ANY_Query";
static const char *anyQueryDefaultAuthSQL =
- "SELECT fqdn, ttl, type, content, zone_id, last_change, auth "
+ "SELECT fqdn, ttl, type, content, zone_id, auth "
"FROM Records "
"WHERE fqdn = lower(:name)"
" AND type IS NOT NULL "
"ORDER BY type";
static const char *anyQueryDefaultSQL =
- "SELECT fqdn, ttl, type, content, zone_id, last_change "
+ "SELECT fqdn, ttl, type, content, zone_id, "
"FROM Records "
"WHERE fqdn = lower(:name)"
" AND type IS NOT NULL "
static const char *anyIdQueryKey = "PDNS_ANY_Id_Query";
static const char *anyIdQueryDefaultAuthSQL =
- "SELECT fqdn, ttl, type, content, zone_id, last_change, auth "
+ "SELECT fqdn, ttl, type, content, zone_id, auth "
"FROM Records "
"WHERE fqdn = lower(:name)"
" AND zone_id = :zoneid"
"ORDER BY type";
static const char *anyIdQueryDefaultSQL =
- "SELECT fqdn, ttl, type, content, zone_id, last_change "
+ "SELECT fqdn, ttl, type, content, zone_id, "
"FROM Records "
"WHERE fqdn = lower(:name)"
" AND zone_id = :zoneid"
static const char *listQueryKey = "PDNS_List_Query";
static const char *listQueryDefaultAuthSQL =
- "SELECT fqdn, ttl, type, content, zone_id, last_change, auth "
+ "SELECT fqdn, ttl, type, content, zone_id, auth "
"FROM Records "
"WHERE zone_id = :zoneid"
" AND type IS NOT NULL "
"ORDER BY fqdn, type";
static const char *listQueryDefaultSQL =
- "SELECT fqdn, ttl, type, content, zone_id, last_change "
+ "SELECT fqdn, ttl, type, content, zone_id, "
"FROM Records "
"WHERE zone_id = :zoneid"
" AND type IS NOT NULL "
ttl NUMBER(10,0) NOT NULL,
type VARCHAR2(32),
content VARCHAR2(2048),
- last_change INTEGER DEFAULT 0 NOT NULL,
auth NUMBER(1,0) DEFAULT 1 NOT NULL,
CONSTRAINT chk_records_fqdn CHECK (fqdn = lower(fqdn)),
CONSTRAINT chk_records_ttl CHECK (ttl BETWEEN 0 AND 4294967295),
addUrlComponent(parameters, "trxid", ss);
req.preparePost();
verb = "POST";
- } else if (method == "calculateSOASerial") {
- addUrlComponent(parameters, "domain", ss);
- req.body = buildMemberListArgs("sd", parameters["sd"]);
- req.headers["content-type"] = "application/x-www-form-urlencoded; charset=utf-8";
- req.headers["content-length"] = std::to_string(req.body.size());
- verb = "POST";
} else if (method == "setDomainMetadata") {
// copy all metadata values into post
std::stringstream ss2;
content VARCHAR(65535) DEFAULT NULL,
ttl INTEGER DEFAULT NULL,
prio INTEGER DEFAULT NULL,
- change_date INTEGER DEFAULT NULL,
ordername VARCHAR(255) DEFAULT NULL,
auth BOOL DEFAULT 0
);
return true;
}
-bool RemoteBackend::calculateSOASerial(const DNSName& domain, const SOAData& sd, uint32_t& serial) {
- Json query = Json::object{
- { "method", "calculateSOASerial" },
- { "parameters", Json::object{
- { "domain", domain.toString() },
- { "sd", Json::object{
- { "qname", sd.qname.toString() },
- { "nameserver", sd.nameserver.toString() },
- { "hostmaster", sd.hostmaster.toString() },
- { "ttl", static_cast<int>(sd.ttl) },
- { "serial", static_cast<double>(sd.serial) },
- { "refresh", static_cast<int>(sd.refresh) },
- { "retry", static_cast<int>(sd.retry) },
- { "expire", static_cast<int>(sd.expire) },
- { "default_ttl", static_cast<int>(sd.default_ttl) },
- { "domain_id", static_cast<int>(sd.domain_id) },
- }}
- }}
- };
-
- Json answer;
- if (this->send(query) == false || this->recv(answer) == false)
- return false;
-
- serial = static_cast<unsigned int>(doubleFromJson(answer,"result"));
- return true;
-}
-
string RemoteBackend::directBackendCmd(const string& querystr) {
Json query = Json::object{
{ "method", "directBackendCmd" },
bool startTransaction(const DNSName& domain, int domain_id) override;
bool commitTransaction() override;
bool abortTransaction() override;
- bool calculateSOASerial(const DNSName& domain, const SOAData& sd, uint32_t& serial) override;
bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) override;
bool deleteTSIGKey(const DNSName& name) override;
bool getTSIGKeys(std::vector< struct TSIGKey > &keys) override;
BOOST_CHECK(be->abortTransaction());
}
-BOOST_AUTO_TEST_CASE(test_method_calculateSOASerial) {
- SOAData sd;
- uint32_t serial;
-
- be->getSOA(DNSName("unit.test."),sd);
- BOOST_CHECK(be->calculateSOASerial(DNSName("unit.test."),sd,serial));
-
- BOOST_CHECK_EQUAL(serial, 2013060300);
-}
-
BOOST_AUTO_TEST_CASE(test_method_directBackendCmd) {
BOOST_TEST_MESSAGE("Testing directBackendCmd method");
BOOST_CHECK_EQUAL(be->directBackendCmd("PING 1234"), "PING 1234");
def do_aborttransaction(args)
[true]
end
-
- def do_calculatesoaserial(args)
- return [2013060300] if args["sd"]["qname"] == "unit.test."
- [false]
- end
def do_directbackendcmd(args)
[args["query"]]
d_UpdateSerialOfZoneQuery=getArg("update-serial-query");
d_UpdateLastCheckofZoneQuery=getArg("update-lastcheck-query");
d_UpdateAccountOfZoneQuery=getArg("update-account-query");
- d_ZoneLastChangeQuery=getArg("zone-lastchange-query");
d_InfoOfAllMasterDomainsQuery=getArg("info-all-master-query");
d_DeleteDomainQuery=getArg("delete-domain-query");
d_DeleteZoneQuery=getArg("delete-zone-query");
d_DeleteZoneQuery_stmt = NULL;
d_DeleteRRSetQuery_stmt = NULL;
d_DeleteNamesQuery_stmt = NULL;
- d_ZoneLastChangeQuery_stmt = NULL;
d_firstOrderQuery_stmt = NULL;
d_beforeOrderQuery_stmt = NULL;
d_afterOrderQuery_stmt = NULL;
return true;
}
-bool GSQLBackend::calculateSOASerial(const DNSName& domain, const SOAData& sd, uint32_t& serial)
-{
- if (d_ZoneLastChangeQuery.empty()) {
- // query not set => fall back to default impl
- return DNSBackend::calculateSOASerial(domain, sd, serial);
- }
-
- try {
- reconnectIfNeeded();
-
- d_ZoneLastChangeQuery_stmt->
- bind("domain_id", sd.domain_id)->
- execute()->
- getResult(d_result)->
- reset();
- }
- catch (const SSqlException& e) {
- //DLOG(g_log<<"GSQLBackend unable to calculate SOA serial: " << e.txtReason()<<endl);
- return false;
- }
-
- if (!d_result.empty()) {
- ASSERT_ROW_COLUMNS("zone-lastchange-query", d_result[0], 1);
- serial = pdns_stou(d_result[0][0]);
- return true;
- }
-
- return false;
-}
-
bool GSQLBackend::listComments(const uint32_t domain_id)
{
try {
d_DeleteZoneQuery_stmt = d_db->prepare(d_DeleteZoneQuery, 1);
d_DeleteRRSetQuery_stmt = d_db->prepare(d_DeleteRRSetQuery, 3);
d_DeleteNamesQuery_stmt = d_db->prepare(d_DeleteNamesQuery, 2);
- d_ZoneLastChangeQuery_stmt = d_db->prepare(d_ZoneLastChangeQuery, 1);
d_firstOrderQuery_stmt = d_db->prepare(d_firstOrderQuery, 1);
d_beforeOrderQuery_stmt = d_db->prepare(d_beforeOrderQuery, 2);
d_afterOrderQuery_stmt = d_db->prepare(d_afterOrderQuery, 2);
d_DeleteZoneQuery_stmt.reset();
d_DeleteRRSetQuery_stmt.reset();
d_DeleteNamesQuery_stmt.reset();
- d_ZoneLastChangeQuery_stmt.reset();
d_firstOrderQuery_stmt.reset();
d_beforeOrderQuery_stmt.reset();
d_afterOrderQuery_stmt.reset();
bool updateEmptyNonTerminals(uint32_t domain_id, set<DNSName>& insert ,set<DNSName>& erase, bool remove) override;
bool doesDNSSEC() override;
- bool calculateSOASerial(const DNSName& domain, const SOAData& sd, uint32_t& serial) override;
-
bool replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<DNSResourceRecord>& rrset) override;
bool listSubZone(const DNSName &zone, int domain_id) override;
bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override;
string d_DeleteZoneQuery;
string d_DeleteRRSetQuery;
string d_DeleteNamesQuery;
- string d_ZoneLastChangeQuery;
string d_firstOrderQuery;
string d_beforeOrderQuery;
unique_ptr<SSqlStatement> d_DeleteZoneQuery_stmt;
unique_ptr<SSqlStatement> d_DeleteRRSetQuery_stmt;
unique_ptr<SSqlStatement> d_DeleteNamesQuery_stmt;
- unique_ptr<SSqlStatement> d_ZoneLastChangeQuery_stmt;
unique_ptr<SSqlStatement> d_firstOrderQuery_stmt;
unique_ptr<SSqlStatement> d_beforeOrderQuery_stmt;
unique_ptr<SSqlStatement> d_afterOrderQuery_stmt;
\param sd SOAData which is filled with the SOA details
\param unmodifiedSerial bool if set, serial will be returned as stored in the backend (maybe 0)
*/
-bool DNSBackend::getSOA(const DNSName &domain, SOAData &sd, bool unmodifiedSerial)
+bool DNSBackend::getSOA(const DNSName &domain, SOAData &sd)
{
this->lookup(QType(QType::SOA),domain);
sd.hostmaster=DNSName("hostmaster")+domain;
}
- if(!unmodifiedSerial && !sd.serial) { // magic time!
- DLOG(g_log<<Logger::Warning<<"Doing SOA serial number autocalculation for "<<rr.qname<<endl);
-
- uint32_t serial = 0;
- if (calculateSOASerial(domain, sd, serial)) {
- sd.serial = serial;
- //DLOG(g_log<<"autocalculated soa serialnumber for "<<rr.qname<<" is "<<newest<<endl);
- } else {
- DLOG(g_log<<"soa serialnumber calculation failed for "<<rr.qname<<endl);
- }
-
- }
sd.db=this;
return true;
}
return ret;
}
-/**
- * Calculates a SOA serial for the zone and stores it in the third
- * argument. Returns false if calculation is not possible for some
- * reason (in this case, the third argument is not inspected). If it
- * returns true, the value returned in the third argument will be set
- * as the SOA serial.
- *
- * \param domain The name of the domain
- * \param sd Information about the SOA record already available
- * \param serial Output parameter. Only inspected when we return true
- */
-bool DNSBackend::calculateSOASerial(const DNSName& domain, const SOAData& sd, uint32_t& serial)
-{
- // we do this by listing the domain and taking the maximum last modified timestamp
-
- DNSResourceRecord i;
- uint32_t newest=0;
-
- if(!(this->list(domain, sd.domain_id))) {
- DLOG(g_log<<Logger::Warning<<"Backend error trying to determine magic serial number of zone '"<<domain<<"'"<<endl);
- return false;
- }
-
- while(this->get(i)) {
- if(i.last_modified>newest)
- newest=i.last_modified;
- }
-
- serial=newest;
-
- return true;
-}
void fillSOAData(const DNSZoneRecord& in, SOAData& sd)
{
sd.domain_id = in.domain_id;
virtual ~DNSBackend(){};
//! fills the soadata struct with the SOA details. Returns false if there is no SOA.
- virtual bool getSOA(const DNSName &name, SOAData &soadata, bool unmodifiedSerial=false);
-
- //! Calculates a SOA serial for the zone and stores it in the third argument.
- virtual bool calculateSOASerial(const DNSName& domain, const SOAData& sd, uint32_t& serial);
+ virtual bool getSOA(const DNSName &name, SOAData &soadata);
virtual bool replaceRRSet(uint32_t domain_id, const DNSName& qname, const QType& qt, const vector<DNSResourceRecord>& rrset)
{
void PacketHandler::increaseSerial(const string &msgPrefix, const DomainInfo *di, bool haveNSEC3, bool narrow, const NSEC3PARAMRecordContent *ns3pr) {
SOAData sd;
- if (!di->backend->getSOA(di->zone, sd, true)) {
+ if (!di->backend->getSOA(di->zone, sd)) {
throw PDNSException("SOA-Serial update failed because there was no SOA. Wowie.");
}
uint32_t oldSerial = sd.serial;
- if (oldSerial == 0) { // using Autoserial, leave the serial alone.
- g_log<<Logger::Notice<<msgPrefix<<"AutoSerial in use in domain \""<<di->zone.toLogString()<<"\", not updating SOA serial."<<endl;
- return;
- }
vector<string> soaEdit2136Setting;
B.getDomainMetadata(di->zone, "SOA-EDIT-DNSUPDATE", soaEdit2136Setting);
}
// not found in neg. or pos. cache, look it up
- return getSOAUncached(domain, sd, false);
+ return getSOAUncached(domain, sd);
}
-bool UeberBackend::getSOAUncached(const DNSName &domain, SOAData &sd, bool unmodifiedSerial)
+bool UeberBackend::getSOAUncached(const DNSName &domain, SOAData &sd)
{
d_question.qtype=QType::SOA;
d_question.qname=domain;
d_question.zoneId=-1;
for(vector<DNSBackend *>::const_iterator i=backends.begin();i!=backends.end();++i)
- if((*i)->getSOA(domain, sd, unmodifiedSerial)) {
- if(d_cache_ttl && !unmodifiedSerial) {
+ if((*i)->getSOA(domain, sd)) {
+ if(d_cache_ttl) {
DNSZoneRecord rr;
rr.dr.d_name = sd.qname;
rr.dr.d_type = QType::SOA;
-
rr.dr.d_content = makeSOAContent(sd);
rr.dr.d_ttl = sd.ttl;
rr.domain_id = sd.domain_id;
/** Determines if we are authoritative for a zone, and at what level */
bool getAuth(const DNSName &target, const QType &qtype, SOAData* sd, bool cachedOk=true);
bool getSOA(const DNSName &domain, SOAData &sd);
- /** Load SOA info from backends, ignoring the cache. Callers that will write to the backend should use this
- * function, possibly setting unmodifiedSerial=true when editing the SOA Serial. */
- bool getSOAUncached(const DNSName &domain, SOAData &sd, bool unmodifiedSerial=false);
+ /** Load SOA info from backends, ignoring the cache.*/
+ bool getSOAUncached(const DNSName &domain, SOAData &sd);
bool get(DNSZoneRecord &r);
void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false);
di.backend->getDomainMetadataOne(zonename, "SOA-EDIT-API", soa_edit_api_kind);
if (!soa_edit_api_kind.empty()) {
SOAData sd;
- if (!B.getSOAUncached(zonename, sd, true))
+ if (!B.getSOAUncached(zonename, sd))
return;
string soa_edit_kind;
// edit SOA (if needed)
if (!soa_edit_api_kind.empty() && !soa_edit_done) {
SOAData sd;
- if (!B.getSOAUncached(zonename, sd, true))
+ if (!B.getSOAUncached(zonename, sd))
throw ApiException("No SOA found for domain '"+zonename.toString()+"'");
DNSResourceRecord rr;
godbc-info-all-slaves-query=select id,name,master,last_check from domains where type='SLAVE'
godbc-info-zone-query=select id,name,master,last_check,notified_serial,type,account from domains where name=?
godbc-insert-comment-query=INSERT INTO comments (domain_id, name, type, modified_at, account, comment) VALUES (?, ?, ?, ?, ?, ?)
-godbc-insert-empty-non-terminal-order-query=insert into records (type,domain_id,disabled,name,ordername,auth,ttl,prio,change_date,content) values (null,?,0,?,?,?,null,null,null,null)
-godbc-insert-record-query=insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth,change_date) values (?,?,?,?,?,?,?,?,?,null)
+godbc-insert-empty-non-terminal-order-query=insert into records (type,domain_id,disabled,name,ordername,auth,ttl,prio,content) values (null,?,0,?,?,?,null,null,null)
+godbc-insert-record-query=insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (?,?,?,?,?,?,?,?,?)
godbc-insert-zone-query=insert into domains (type,name,master,account,last_check,notified_serial) values(?, ?, ?, ?, null, null)
godbc-list-comments-query=SELECT domain_id,name,type,modified_at,account,comment FROM comments WHERE domain_id=?
godbc-list-domain-keys-query=select cryptokeys.id, flags, active, content from domains, cryptokeys where cryptokeys.domain_id=domains.id and name=?
godbc-update-ordername-and-auth-query=update records set ordername=?,auth=? where domain_id=? and name=? and disabled=0
godbc-update-ordername-and-auth-type-query=update records set ordername=?,auth=? where domain_id=? and name=? and type=? and disabled=0
godbc-update-serial-query=update domains set notified_serial=? where id=?
-godbc-zone-lastchange-query=select max(change_date) from records where domain_id=?
__EOF__
gsql_master godbc_sqlite3 nodyndns