]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Adds missing ASSERT_ROW_COLUMNS to gsql and bind
authorBenjamin Zengin <b.zengin@yahoo.de>
Thu, 21 Jul 2016 13:41:02 +0000 (15:41 +0200)
committerBenjamin Zengin <b.zengin@yahoo.de>
Tue, 6 Sep 2016 10:09:19 +0000 (12:09 +0200)
modules/bindbackend/binddnssec.cc
pdns/backends/gsql/gsqlbackend.cc

index 6d91db2331259bfa774e2ec7fc38a00670772bc2..b432e3067f221a8ed048a3d145ead4c6a5d3e80f 100644 (file)
@@ -89,6 +89,8 @@ void Bind2Backend::freeStatements()
 #include "pdns/logger.hh"
 #include "pdns/ssqlite3.hh"
 
+#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())); } }
+
 void Bind2Backend::setupDNSSEC()
 {
   if(getArg("dnssec-db").empty() || d_hybrid)
@@ -334,6 +336,7 @@ bool Bind2Backend::addDomainKey(const DNSName& name, const KeyData& key, int64_t
     }
     SSqlStatement::row_t row;
     d_GetLastInsertedKeyIdQuery_stmt->nextRow(row);
+    ASSERT_ROW_COLUMNS("get-last-inserted-key-id-query", row, 1);
     int id = std::stoi(row[0]);
     d_GetLastInsertedKeyIdQuery_stmt->reset();
     return true;
index 8c01b14afdadcbae46e7416279863b60b72d3af5..da28653d0620ab10cfbca6dd39f20c48dcfd839a 100644 (file)
@@ -671,6 +671,7 @@ bool GSQLBackend::addDomainKey(const DNSName& name, const KeyData& key, int64_t&
     }
     SSqlStatement::row_t row;
     d_GetLastInsertedKeyIdQuery_stmt->nextRow(row);
+    ASSERT_ROW_COLUMNS("get-last-inserted-key-id-query", row, 1);
     id = std::stoi(row[0]);
     d_GetLastInsertedKeyIdQuery_stmt->reset();
     return true;