#include <boost/format.hpp>
#include <boost/scoped_ptr.hpp>
-#define ASSERT_ROW_COLUMNS(query, row, num) { if (row.size() != num) { throw DBException(std::string(query) + " returned wrong number of columns, expected " #num ", got " + std::to_string(row.size())); } }
+#define ASSERT_ROW_COLUMNS(query, row, num) { if (row.size() != num) { throw PDNSException(std::string(query) + " returned wrong number of columns, expected " #num ", got " + std::to_string(row.size())); } }
GSQLBackend::GSQLBackend(const string &mode, const string &suffix)
{
reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason());
}
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason());
}
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason());
}
if(!d_result.empty()) {
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to set master of domain \""+domain.toString()+"\": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to set master of domain \""+domain.toString()+"\": "+e.txtReason());
}
return true;
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to set kind of domain \""+domain.toString()+"\": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to set kind of domain \""+domain.toString()+"\": "+e.txtReason());
}
return true;
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to set account of domain \""+domain.toString()+"\": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to set account of domain \""+domain.toString()+"\": "+e.txtReason());
}
return true;
}
reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to retrieve information about a domain: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve information about a domain: "+e.txtReason());
}
int numanswers=d_result.size();
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to retrieve list of slave domains: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve list of slave domains: "+e.txtReason());
}
vector<DomainInfo> allSlaves;
reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason());
}
vector<DomainInfo> allMasters;
reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to update ordername and auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to update ordername and auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
} else {
try {
reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to update ordername and auth per type for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to update ordername and auth per type for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
}
} else {
reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to nullify ordername and update auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to nullify ordername and update auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
} else {
try {
reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to nullify ordername and update auth per type for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to nullify ordername and update auth per type for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
}
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to delete empty non-terminal records from domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete empty non-terminal records from domain_id "+itoa(domain_id)+": "+e.txtReason());
return false;
}
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to delete empty non-terminal rr "+qname.toString()+" from domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete empty non-terminal rr "+qname.toString()+" from domain_id "+itoa(domain_id)+": "+e.txtReason());
return false;
}
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to insert empty non-terminal rr "+qname.toString()+" in domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to insert empty non-terminal rr "+qname.toString()+" in domain_id "+itoa(domain_id)+": "+e.txtReason());
return false;
}
}
d_afterOrderQuery_stmt->reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+": "+e.txtReason());
}
if(after.empty() && !qname.empty()) {
d_firstOrderQuery_stmt->reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+": "+e.txtReason());
}
}
d_beforeOrderQuery_stmt->reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+": "+e.txtReason());
}
if(! unhashed.empty())
d_lastOrderQuery_stmt->reset();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend unable to find before/after (last) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (last) for domain_id "+itoa(id)+": "+e.txtReason());
}
} else {
before=qname;
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to store key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to store key: "+e.txtReason());
}
return 1; // XXX FIXME, no idea how to get the id
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to activate key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to activate key: "+e.txtReason());
}
return true;
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to deactivate key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to deactivate key: "+e.txtReason());
}
return true;
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to remove key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to remove key: "+e.txtReason());
}
return true;
}
d_getTSIGKeyQuery_stmt->reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to retrieve named TSIG key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve named TSIG key: "+e.txtReason());
}
return !content->empty();
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to store named TSIG key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to store named TSIG key: "+e.txtReason());
}
return true;
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to store named TSIG key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to store named TSIG key: "+e.txtReason());
}
return true;
}
d_getTSIGKeysQuery_stmt->reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to retrieve TSIG keys: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve TSIG keys: "+e.txtReason());
}
return keys.empty();
d_ListDomainKeysQuery_stmt->reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to list keys: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to list keys: "+e.txtReason());
}
return true;
d_GetAllDomainMetadataQuery_stmt->reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to list metadata: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to list metadata: "+e.txtReason());
}
return true;
d_GetDomainMetadataQuery_stmt->reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to list metadata: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to list metadata: "+e.txtReason());
}
return true;
}
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to store metadata key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to store metadata key: "+e.txtReason());
}
return true;
execute();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend lookup query: "+e.txtReason());
+ throw PDNSException("GSQLBackend lookup query:"+e.txtReason());
}
d_qname=qname;
execute();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend list query: "+e.txtReason());
+ throw PDNSException("GSQLBackend list query: "+e.txtReason());
}
d_qname.clear();
execute();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend listSubZone query: "+e.txtReason());
+ throw PDNSException("GSQLBackend listSubZone query: "+e.txtReason());
}
d_qname.clear();
return true;
d_query_stmt->nextRow(row);
ASSERT_ROW_COLUMNS(d_query_name, row, 8);
} catch (SSqlException &e) {
- throw DBException("GSQLBackend get: "+e.txtReason());
+ throw PDNSException("GSQLBackend get: "+e.txtReason());
}
try {
extractRecord(row, r);
try {
d_query_stmt->reset();
} catch (SSqlException &e) {
- throw DBException("GSQLBackend get: "+e.txtReason());
+ throw PDNSException("GSQLBackend get: "+e.txtReason());
}
d_query_stmt = NULL;
return false;
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to search for a domain: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to search for a domain: "+e.txtReason());
}
if(!d_result.empty()) {
ASSERT_ROW_COLUMNS("supermaster-query", d_result[0], 1);
reset();
}
catch(SSqlException &e) {
- throw DBException("Database error trying to insert new domain '"+domain.toString()+"': "+ e.txtReason());
+ throw PDNSException("Database error trying to insert new domain '"+domain.toString()+"': "+ e.txtReason());
}
return true;
}
createDomain(domain, "SLAVE", masters, account);
}
catch(SSqlException &e) {
- throw DBException("Database error trying to insert new slave domain '"+domain.toString()+"': "+ e.txtReason());
+ throw PDNSException("Database error trying to insert new slave domain '"+domain.toString()+"': "+ e.txtReason());
}
return true;
}
reset();
}
catch(SSqlException &e) {
- throw DBException("Database error trying to delete domain '"+domain.toString()+"': "+ e.txtReason());
+ throw PDNSException("Database error trying to delete domain '"+domain.toString()+"': "+ e.txtReason());
}
return true;
}
d_getAllDomainsQuery_stmt->reset();
}
catch (SSqlException &e) {
- throw DBException("Database error trying to retrieve all domains: " + e.txtReason());
+ throw PDNSException("Database error trying to retrieve all domains:" + e.txtReason());
}
}
}
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to delete RRSet: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete RRSet: "+e.txtReason());
}
if (rrset.empty()) {
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to delete comment: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete comment: "+e.txtReason());
}
}
for(const auto& rr: rrset) {
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to feed record: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed record: "+e.txtReason());
}
return true; // XXX FIXME this API should not return 'true' I think -ahu
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason());
}
}
return true;
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason());
}
}
return true;
}
}
catch (SSqlException &e) {
- throw DBException("Database failed to start transaction: "+e.txtReason());
+ throw PDNSException("Database failed to start transaction: "+e.txtReason());
}
return true;
d_db->commit();
}
catch (SSqlException &e) {
- throw DBException("Database failed to commit transaction: "+e.txtReason());
+ throw PDNSException("Database failed to commit transaction: "+e.txtReason());
}
return true;
}
d_db->rollback();
}
catch(SSqlException &e) {
- throw DBException("Database failed to abort transaction: "+string(e.txtReason()));
+ throw PDNSException("Database failed to abort transaction: "+string(e.txtReason()));
}
return true;
}
execute();
}
catch(SSqlException &e) {
- throw DBException("GSQLBackend list comments query: "+e.txtReason());
+ throw PDNSException("GSQLBackend list comments query: "+e.txtReason());
}
return true;
try {
d_query_stmt->reset();
} catch(SSqlException &e) {
- throw DBException("GSQLBackend comment get: "+e.txtReason());
+ throw PDNSException("GSQLBackend comment get: "+e.txtReason());
}
d_query_stmt = NULL;
return false;
d_query_stmt->nextRow(row);
ASSERT_ROW_COLUMNS(d_query_name, row, 6);
} catch(SSqlException &e) {
- throw DBException("GSQLBackend comment get: "+e.txtReason());
+ throw PDNSException("GSQLBackend comment get: "+e.txtReason());
}
try {
extractComment(row, comment);
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to feed comment: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed comment: "+e.txtReason());
}
}
reset();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to delete comment: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete comment: "+e.txtReason());
}
for(const auto& comment: comments) {
return out.str();
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to execute query: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to execute query: "+e.txtReason());
}
}
return true;
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to execute query: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to execute query: "+e.txtReason());
}
return false;
return true;
}
catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to execute query: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to execute query: "+e.txtReason());
}
return false;
return true;
}
} catch (SSqlException &e) {
- throw DBException("GSQLBackend unable to verify ownership of domain: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to verify ownership of domain: "+e.txtReason());
}
return false;