]> granicus.if.org Git - pdns/commitdiff
goracle backend query/schema updates
authorKees Monshouwer <mind04@monshouwer.org>
Tue, 31 Dec 2013 08:15:04 +0000 (09:15 +0100)
committermind04 <mind04@monshouwer.org>
Wed, 1 Jan 2014 09:01:26 +0000 (10:01 +0100)
modules/goraclebackend/goracle-schema.sql
modules/goraclebackend/goraclebackend.cc

index bc70b1b21dd409e086117830f6529be8680206e4..4e826e48030d4d17569ac414a27d1c94a637b028 100644 (file)
@@ -1,72 +1,76 @@
 create table domains (
id             NUMBER,
name           VARCHAR(255) NOT NULL,
master                 VARCHAR(128) DEFAULT NULL,
last_check     INT DEFAULT NULL,
type           VARCHAR(6) NOT NULL,
- notified_serial INT DEFAULT NULL, 
- account         VARCHAR(40) DEFAULT NULL,
- primary key (id)
      id              NUMBER,
      name            VARCHAR(255) NOT NULL,
      master          VARCHAR(128) DEFAULT NULL,
      last_check      INT DEFAULT NULL,
      type            VARCHAR(6) NOT NULL,
+       notified_serial INT DEFAULT NULL,
      account         VARCHAR(40) DEFAULT NULL,
      primary key (id)
 );
 
-create sequence DOMAINS_ID_SEQUENCE; 
+create sequence DOMAINS_ID_SEQUENCE;
 create index DOMAINS$NAME on domains (NAME);
+
+
 CREATE TABLE records (
-        id              number(11) not NULL,
-        domain_id       INT DEFAULT NULL REFERENCES Domains(ID) ON DELETE CASCADE,
-        name            VARCHAR(255) DEFAULT NULL,
-        type            VARCHAR(10) DEFAULT NULL,
-        content         VARCHAR2(4000) DEFAULT NULL,
-        ttl             INT DEFAULT NULL,
-        prio            INT DEFAULT NULL,
-        change_date     INT DEFAULT NULL, 
-        ordername       VARCHAR(255) DEFAULT NULL,
-        auth            INT DEFAULT NULL,
+       id              number(11) not NULL,
+       domain_id       INT DEFAULT NULL REFERENCES Domains(ID) ON DELETE CASCADE,
+       name            VARCHAR(255) DEFAULT NULL,
+       type            VARCHAR(10) DEFAULT NULL,
+       content         VARCHAR2(4000) DEFAULT NULL,
+       ttl             INT DEFAULT NULL,
+       prio            INT DEFAULT NULL,
+       change_date     INT DEFAULT NULL,
+       ordername       VARCHAR(255) DEFAULT NULL,
+       auth            INT DEFAULT NULL,
        primary key (id)
 );
 
 create index RECORDS$NAME on RECORDS (NAME);
+create index records$domainidordername on records (domain_id, ordername);
 create sequence RECORDS_ID_SEQUENCE;
 
+
 create table supermasters (
-         ip VARCHAR(64) NOT NULL, 
-         nameserver VARCHAR(255) NOT NULL, 
-         account VARCHAR(40) DEFAULT NULL,
-         PRIMARY KEY(ip, nameserver)
+       ip              VARCHAR(64) NOT NULL,
+       nameserver      VARCHAR(255) NOT NULL,
+       account         VARCHAR(40) DEFAULT NULL,
+       PRIMARY KEY(ip, nameserver)
 );
 
+
 create table domainmetadata (
id         NUMBER,
domain_id  INT NOT NULL,
kind       VARCHAR(16),
content    VARCHAR2(4000),
- primary key(id)
      id              NUMBER,
      domain_id       INT NOT NULL,
      kind            VARCHAR(16),
      content         VARCHAR2(4000),
      primary key(id)
 );
 
 create sequence DOMAINMETADATA_ID_SEQUENCE;
-create index domainmetadata$domainid on domainmetadata(domain_id);               
+create index domainmetadata$domainid on domainmetadata(domain_id);
+
 
 create table cryptokeys (
id         NUMBER,
domain_id  INT NOT NULL,
flags      INT NOT NULL,
active     INT NOT NULL,
content    VARCHAR2(4000),
- primary key(id)
-);       
      id              NUMBER,
      domain_id       INT NOT NULL,
      flags           INT NOT NULL,
      active          INT NOT NULL,
      content         VARCHAR2(4000),
      primary key(id)
+);
 
 create sequence CRYPTOKEYS_ID_SEQUENCE;
-create index cryptokeys$domainid on cryptokeys(domain_id);           
+create index cryptokeys$domainid on cryptokeys(domain_id);
 
-create index records$domainidordername on records (domain_id, ordername);
 
 create table tsigkeys (
id         NUMBER,
- name       VARCHAR(255), 
algorithm  VARCHAR(50),
secret     VARCHAR(255),
- primary key(id)
      id              NUMBER,
+       name            VARCHAR(255),
      algorithm       VARCHAR(50),
      secret          VARCHAR(255),
      primary key(id)
 );
 
 create sequence TSIGKEYS_ID_SEQUENCE;
index eebcef97f238589921bd8643d9119dc525311306..94373a4ea18be93353b78c5e1140f09118bf8eb9 100644 (file)
@@ -64,7 +64,7 @@ public:
     declare(suffix,"list-query","AXFR query", "select content,ttl,prio,type,domain_id,name from records where domain_id='%d'");
 
     declare(suffix,"remove-empty-non-terminals-from-zone-query", "remove all empty non-terminals from zone", "delete from records where domain_id='%d' and type is null");
-    declare(suffix,"insert-empty-non-terminal-query", "insert empty non-terminal in zone", "insert into records (domain_id,name,type) values ('%d','%s',null)");
+    declare(suffix,"insert-empty-non-terminal-query", "insert empty non-terminal in zone", "insert into records (id,domain_id,name,type) values (records_id_sequence.nextval,'%d','%s',null)");
     declare(suffix,"delete-empty-non-terminal-query", "delete empty non-terminal from zone", "delete from records where domain_id='%d' and name='%s' and type is null");
 
     // and now with auth
@@ -80,7 +80,7 @@ public:
 
     declare(suffix,"list-query-auth","AXFR query", "select content,ttl,prio,type,domain_id,name, auth from records where domain_id='%d' order by name, type");
 
-    declare(suffix,"insert-empty-non-terminal-query-auth", "insert empty non-terminal in zone", "insert into records (domain_id,name,type,auth) values ('%d','%s',null,'1')");
+    declare(suffix,"insert-empty-non-terminal-query-auth", "insert empty non-terminal in zone", "insert into records (id,domain_id,name,type,auth) values (records_id_sequence.nextval,'%d','%s',null,'1')");
 
     declare(suffix,"master-zone-query","Data", "select master from domains where name='%s' and type='SLAVE'");
 
@@ -95,16 +95,16 @@ public:
 
     declare(suffix,"insert-record-query","", "insert into records (id, content,ttl,prio,type,domain_id,name) values (records_id_sequence.nextval, '%s',%d,%d,'%s',%d,'%s')");
     declare(suffix,"insert-record-query-auth","", "insert into records (id, content,ttl,prio,type,domain_id,name,auth) values (records_id_sequence.nextval, '%s',%d,%d,'%s',%d,'%s','%d')");
-    declare(suffix,"insert-record-order-query-auth","", "insert into records (id, content,ttl,prio,type,domain_id,name,ordername,auth) values (records_id_sequence.nextval, '%s',%d,%d,'%s',%d,'%s','%s','%d')");
+    declare(suffix,"insert-record-order-query-auth","", "insert into records (id, content,ttl,prio,type,domain_id,name,ordername,auth) values (records_id_sequence.nextval, '%s',%d,%d,'%s',%d,'%s','%s ','%d')");
     declare(suffix,"insert-ent-query", "insert empty non-terminal in zone", "insert into records (id, type,domain_id,name) values (records_id_sequence.nextval, null,'%d','%s')");
     declare(suffix,"insert-ent-query-auth", "insert empty non-terminal in zone", "insert into records (id, type,domain_id,name,auth) values (records_id_sequence.nextval, null,'%d','%s','1')");
     declare(suffix,"insert-ent-order-query-auth", "insert empty non-terminal in zone", "insert into records (id, type,domain_id,name,ordername,auth) values (records_id_sequence.nextval, null,'%d','%s','%s','1')");
 
-    declare(suffix,"get-order-first-query","DNSSEC Ordering Query, first", "select ordername, name from records where domain_id=%d and ordername is not null and rownum=1 order by 1 asc");
-    declare(suffix,"get-order-before-query","DNSSEC Ordering Query, before", "select ordername, name from records where ordername <= '%s' and domain_id=%d and ordername is not null and rownum=1 order by 1 desc");
-    declare(suffix,"get-order-after-query","DNSSEC Ordering Query, after", "select min(ordername) from records where ordername > '%s' and domain_id=%d and ordername is not null");
-    declare(suffix,"get-order-last-query","DNSSEC Ordering Query, last", "select ordername, name from records where ordername != '' and domain_id=%d and ordername is not null and rownum=1 order by 1 desc");
-    declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s',auth=%d where name='%s' and domain_id='%d'");
+    declare(suffix,"get-order-first-query","DNSSEC Ordering Query, first", "select trim(ordername),name from records where domain_id=%d and ordername is not null and rownum=1 order by ordername asc");
+    declare(suffix,"get-order-before-query","DNSSEC Ordering Query, before", "select trim(ordername), name from records where ordername <= '%s ' and domain_id=%d and ordername is not null and rownum=1 order by ordername desc");
+    declare(suffix,"get-order-after-query","DNSSEC Ordering Query, after", "select trim(min(ordername)) from records where ordername > '%s ' and domain_id=%d and ordername is not null");
+    declare(suffix,"get-order-last-query","DNSSEC Ordering Query, last", "select trim(ordername), name from records where ordername != ' ' and domain_id=%d and ordername is not null and rownum=1 order by ordername desc");
+    declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s ',auth=%d where name='%s' and domain_id='%d'");
     declare(suffix,"set-auth-on-ds-record-query", "DNSSEC set auth on a DS record", "update records set auth=1 where domain_id='%d' and name='%s' and type='DS'");
 
     declare(suffix,"nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth query", "update records set ordername=NULL,auth=%d where domain_id='%d' and name='%s'");
@@ -125,13 +125,13 @@ public:
     declare(suffix,"get-domain-metadata-query","", "select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name='%s' and domainmetadata.kind='%s'");
     declare(suffix,"clear-domain-metadata-query","", "delete from domainmetadata where domain_id=(select id from domains where name='%s') and domainmetadata.kind='%s'");
     declare(suffix,"clear-domain-all-metadata-query","", "delete from domainmetadata where domain_id=(select id from domains where name='%s')");
-    declare(suffix,"set-domain-metadata-query","", "insert into domainmetadata (id, domain_id, kind, content) select domainmetadata_sequence_id.nextval, id, '%s', '%s' from domains where name='%s'");
+    declare(suffix,"set-domain-metadata-query","", "insert into domainmetadata (id, domain_id, kind, content) select domainmetadata_id_sequence.nextval, id, '%s', '%s' from domains where name='%s'");
     declare(suffix,"activate-domain-key-query","", "update cryptokeys set active=1 where domain_id=(select id from domains where name='%s') and  cryptokeys.id=%d");
     declare(suffix,"deactivate-domain-key-query","", "update cryptokeys set active=0 where domain_id=(select id from domains where name='%s') and  cryptokeys.id=%d");
     declare(suffix,"remove-domain-key-query","", "delete from cryptokeys where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d");
     declare(suffix,"clear-domain-all-keys-query","", "delete from cryptokeys where domain_id=(select id from domains where name='%s')");
     declare(suffix,"get-tsig-key-query","", "select algorithm, secret from tsigkeys where name='%s'");
-    declare(suffix,"set-tsig-key-query","", "insert into tsigkeys (name,algorithm,secret) VALUES('%s','%s','%s')");
+    declare(suffix,"set-tsig-key-query","", "insert into tsigkeys (id,name,algorithm,secret) VALUES(tsigkeys_id_sequence.nextval,'%s','%s','%s')");
     declare(suffix,"delete-tsig-key-query","", "delete from tsigkeys where name='%s'");
     declare(suffix,"get-tsig-keys-query","", "select name,algorithm, secret from tsigkeys");