|
-- |
|
-- Domain and zone manipulation |
|
-- https://doc.powerdns.com/authoritative/backends/generic-sql.html#domain-and-zone-manipulation |
|
-- |
|
|
|
-- gsqlite3-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. |
|
-- MISSING |
|
|
|
-- gsqlite3-insert-zone-query |
|
-- Add a new domain. This query also requires the type, masters and account fields |
|
insert into domains (type, name, master, account, last_check, notified_serial) |
|
values (:type, :domain, :masters, :account, null, null); |
|
|
|
-- gsqlite3-update-kind-query |
|
-- Called to update the type of domain. |
|
update domains |
|
set type = :kind |
|
where name = :domain; |
|
|
|
-- gsqlite3-delete-zone-query |
|
-- Called to delete all records of a zone. Used before an incoming AXFR. |
|
delete from records |
|
where domain_id = :domain_id; |
|
|
|
-- gsqlite3-delete-domain-query |
|
-- Called to delete a domain from the domains-table. |
|
delete from domains |
|
where name = :domain; |
|
|
|
-- gsqlite3-get-all-domains-query |
|
-- Used to get information on all active domains. |
|
select domains.id, domains.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check, domains.account |
|
from domains |
|
left join records on records.domain_id = domains.id |
|
and records.type = 'SOA' |
|
and records.name = domains.name |
|
where records.disabled = 0 |
|
or :include_disabled; |
|
|
|
-- gsqlite3-info-zone-query |
|
-- Called to retrieve (nearly) all information for a domain. |
|
select id, name, master, last_check, notified_serial, type, account |
|
from domains |
|
where name = :domain; |
|
|
|
-- gsqlite3-insert-record-query |
|
-- Called during incoming AXFR. |
|
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); |
|
|
|
-- gsqlite3-update-account-query |
|
-- Set the account for a domain. |
|
update domains |
|
set account = :account |
|
where name = :domain; |
|
|
|
-- gsqlite3-delete-names-query |
|
-- Called to delete all records of a certain name. |
|
delete from records |
|
where domain_id = :domain_id |
|
and name = :qname; |
|
|
|
-- gsqlite3-delete-rrset-query |
|
-- Called to delete an RRset based on domain_id, name and type. |
|
delete from records |
|
where domain_id = :domain_id |
|
and name = :qname |
|
and type = :qtype; |
|
|
|
-- gsqlite3-get-all-domain-metadata-query |
|
-- Get all domain metadata for a domain. |
|
-- https://doc.powerdns.com/authoritative/domainmetadata.html |
|
select kind, content |
|
from domains, domainmetadata |
|
where domainmetadata.domain_id = domains.id |
|
and name = :domain; |
|
|
|
-- gsqlite3-get-domain-metadata-query |
|
-- Get a single piece of domain metadata. |
|
-- https://doc.powerdns.com/authoritative/domainmetadata.html |
|
select content |
|
from domains, domainmetadata |
|
where domainmetadata.domain_id = domains.id |
|
and name = :domain |
|
and domainmetadata.kind = :kind; |
|
|
|
-- gsqlite3-clear-domain-metadata-query |
|
-- Delete a single entry of domain metadata. |
|
delete from domainmetadata |
|
where domain_id = (select id from domains where name = :domain) |
|
and domainmetadata.kind = :kind; |
|
|
|
-- gsqlite3-clear-domain-all-metadata-query |
|
-- Remove all domain metadata for a domain. |
|
delete from domainmetadata |
|
where domain_id = (select id from domains where name = :domain); |
|
|
|
-- gsqlite3-set-domain-metadata-query |
|
-- Add domain metadata for a zone. |
|
insert into domainmetadata (domain_id, kind, content) |
|
select id, :kind, :content from domains where name = :domain; |
|
|
|
-- gsqlite3-add-domain-key-query |
|
-- Called to a cryptokey to a domain. |
|
insert into cryptokeys (domain_id, flags, active, content) |
|
select id, :flags, :active, :content |
|
from domains |
|
where name = :domain; |
|
|
|
-- gsqlite3-list-domain-keys-query |
|
-- Called to get all cryptokeys for a domain. |
|
select cryptokeys.id, flags, active, content |
|
from domains, cryptokeys |
|
where cryptokeys.domain_id = domains.id |
|
and name = :domain; |
|
|
|
-- gsqlite3-activate-domain-key-query |
|
-- Called to set a cryptokey to active. |
|
update cryptokeys |
|
set active = 1 |
|
where domain_id = (select id from domains where name = :domain) |
|
and cryptokeys.id = :key_id; |
|
|
|
-- gsqlite3-deactivate-domain-key-query |
|
-- Called to set a cryptokey to inactive. |
|
update cryptokeys |
|
set active = 0 |
|
where domain_id = (select id from domains where name = :domain) |
|
and cryptokeys.id = :key_id; |
|
|
|
-- gsqlite3-clear-domain-all-keys-query |
|
-- Called to remove all DNSSEC keys for a zone. |
|
delete from cryptokeys |
|
where domain_id = (select id from domains where name = :domain); |
|
|
|
-- gsqlite3-remove-domain-key-query |
|
-- Called to remove a crypto key. |
|
delete from cryptokeys |
|
where domain_id = (select id from domains where name = :domain) |
|
and cryptokeys.id = :key_id; |