Show
Ignore:
Timestamp:
01/04/11 21:59:54 (2 years ago)
Author:
ahu
Message:

On his birthday, José Arthur Benetasso Villanova gave us initial postgresql code for PowerDNSSEC! ;-)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/modules/gpgsqlbackend/gpgsqlbackend.cc

    r1804 r1807  
    1414 
    1515#include "spgsql.hh" 
    16  
    17  
    1816#include <sstream> 
    1917 
     
    2725                  getArg("user"), 
    2826                  getArg("password"))); 
    29      
    3027  } 
    3128   
     
    5249    declare(suffix,"password","Pdns backend password to connect with",""); 
    5350    declare(suffix, "dnssec", "Assume DNSSEC Schema is in place","no"); 
     51 
    5452    declare(suffix,"basic-query","Basic query","select content,ttl,prio,type,domain_id,name from records where type='%s' and name='%s'"); 
    5553    declare(suffix,"id-query","Basic with ID query","select content,ttl,prio,type,domain_id,name from records where type='%s' and name='%s' and domain_id=%d"); 
     
    6361 
    6462    declare(suffix,"list-query","AXFR query", "select content,ttl,prio,type,domain_id,name from records where domain_id='%d'"); 
     63   
     64    // and now with auth 
     65    declare(suffix,"basic-query-auth","Basic query","select content,ttl,prio,type,domain_id,name, case when auth then 1 else 0 end as auth from records where type='%s' and name='%s'"); 
     66    declare(suffix,"id-query-auth","Basic with ID query","select content,ttl,prio,type,domain_id,name, case when auth then 1 else 0 end as auth from records where type='%s' and name='%s' and domain_id=%d"); 
     67    declare(suffix,"wildcard-query-auth","Wildcard query","select content,ttl,prio,type,domain_id,name, case when auth then 1 else 0 end as auth from records where type='%s' and name like '%s'"); 
     68    declare(suffix,"wildcard-id-query-auth","Wildcard with ID query","select content,ttl,prio,type,domain_id,name, case when auth true then 1 else 0 end as auth from records where type='%s' and name like '%s' and domain_id='%d'"); 
     69 
     70    declare(suffix,"any-query-auth","Any query","select content,ttl,prio,type,domain_id,name, case when auth then 1 else 0 end as auth from records where name='%s'"); 
     71    declare(suffix,"any-id-query-auth","Any with ID query","select content,ttl,prio,type,domain_id,name, case when auth then 1 else 0 end as auth from records where name='%s' and domain_id=%d"); 
     72    declare(suffix,"wildcard-any-query-auth","Wildcard ANY query","select content,ttl,prio,type,domain_id,name, case when auth then 1 else 0 end as auth from records where name like '%s'"); 
     73    declare(suffix,"wildcard-any-id-query-auth","Wildcard ANY with ID query","select content,ttl,prio,type,domain_id,name, case when auth then 1 else 0 end as auth from records where name like '%s' and domain_id='%d'"); 
     74 
     75    declare(suffix,"list-query-auth","AXFR query", "select content,ttl,prio,type,domain_id,name, case when auth then 1 else 0 end as auth from records where domain_id='%d'"); 
     76     
     77     
     78     
    6579    declare(suffix,"master-zone-query","Data", "select master from domains where name='%s' and type='SLAVE'"); 
    6680 
     
    7185    declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE','%s','%s','%s')"); 
    7286    declare(suffix,"insert-record-query","", "insert into records (content,ttl,prio,type,domain_id,name) values ('%s',%d,%d,'%s',%d,'%s')"); 
     87     
     88    declare(suffix,"get-order-before-query","DNSSEC Ordering Query, before", "select ordername, name from records where ordername <= '%s' and auth and domain_id=%d order by 1 desc limit 1"); 
     89    declare(suffix,"get-order-after-query","DNSSEC Ordering Query, afer", "select min(ordername) from records where ordername > '%s' and auth and domain_id=%d"); 
     90    declare(suffix,"set-order-and-auth-query", "DNSSEC set ordering query", "update records set ordername='%s',auth=(%d = 1) where name='%s' and domain_id='%d'"); 
     91     
     92     
    7393    declare(suffix,"update-serial-query","", "update domains set notified_serial=%d where id=%d"); 
    7494    declare(suffix,"update-lastcheck-query","", "update domains set last_check=%d where id=%d"); 
     
    7797    declare(suffix,"check-acl-query","", "select value from acls where acl_type='%s' and acl_key='%s'"); 
    7898 
    79     declare(suffix,"add-domain-key-query","", "insert into cryptokeys (domain_id, flags, active, content) select id, %d, %d, '%s' from domains where name='%s'"); 
    80     declare(suffix,"list-domain-keys-query","", "select cryptokeys.id, flags, active, content from domains, cryptokeys where domain_id=domains.id and name='%s'"); 
     99    declare(suffix,"add-domain-key-query","", "insert into cryptokeys (domain_id, flags, active, content) select id, %d, (%d = 1), '%s' from domains where name='%s'"); 
     100    declare(suffix,"list-domain-keys-query","", "select cryptokeys.id, flags, case when active then 1 else 0 end as active, content from domains, cryptokeys where domain_id=domains.id and name='%s'"); 
    81101    declare(suffix,"get-domain-metadata-query","", "select content from domains, domainmetadata where domain_id=domains.id and name='%s' and domainmetadata.kind='%s'"); 
    82102    declare(suffix,"clear-domain-metadata-query","", "delete from domainmetadata where domain_id=(select id from domains where name='%s') and domainmetadata.kind='%s'"); 
    83103    declare(suffix,"set-domain-metadata-query","", "insert into domainmetadata (domain_id, kind, content) select id, '%s', '%s' from domains where name='%s'"); 
    84     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"); 
    85     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"); 
     104    declare(suffix,"activate-domain-key-query","", "update cryptokeys set active=true where domain_id=(select id from domains where name='%s') and  cryptokeys.id=%d"); 
     105    declare(suffix,"deactivate-domain-key-query","", "update cryptokeys set active=false where domain_id=(select id from domains where name='%s') and  cryptokeys.id=%d"); 
    86106    declare(suffix,"remove-domain-key-query","", "delete from cryptokeys where domain_id=(select id from domains where name='%s') and cryptokeys.id=%d");     
    87107