]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
catch sql exceptions in replaceRRSet and replaceComments 1324/head
authorKees Monshouwer <mind04@monshouwer.org>
Fri, 7 Mar 2014 19:30:43 +0000 (20:30 +0100)
committermind04 <mind04@monshouwer.org>
Fri, 7 Mar 2014 19:34:22 +0000 (20:34 +0100)
pdns/backends/gsql/gsqlbackend.cc

index ed3b32a140c46ed4d24b20372e9800bf618217cc..1a42736b0a09694922bd9572955490996b130793 100644 (file)
@@ -1104,7 +1104,13 @@ bool GSQLBackend::replaceRRSet(uint32_t domain_id, const string& qname, const QT
              % sqlEscape(qname)
       ).str();
   }
-  d_db->doCommand(query);
+  try {
+    d_db->doCommand(query);
+  }
+  catch (SSqlException &e) {
+    throw PDNSException("GSQLBackend unable to delete RRSet: "+e.txtReason());
+  }
+
   if (rrset.empty()) {
     // zap comments for now non-existing rrset
     query = (boost::format(d_DeleteCommentRRsetQuery)
@@ -1112,7 +1118,12 @@ bool GSQLBackend::replaceRRSet(uint32_t domain_id, const string& qname, const QT
              % sqlEscape(qname)
              % sqlEscape(qt.getName())
       ).str();
-    d_db->doCommand(query);
+    try {
+      d_db->doCommand(query);
+    }
+    catch (SSqlException &e) {
+      throw PDNSException("GSQLBackend unable to delete comment: "+e.txtReason());
+    }
   }
   BOOST_FOREACH(const DNSResourceRecord& rr, rrset) {
     feedRecord(rr);
@@ -1365,7 +1376,12 @@ bool GSQLBackend::replaceComments(const uint32_t domain_id, const string& qname,
              % sqlEscape(qt.getName())
       ).str();
 
-  d_db->doCommand(query);
+  try {
+    d_db->doCommand(query);
+  }
+  catch (SSqlException &e) {
+    throw PDNSException("GSQLBackend unable to delete comment: "+e.txtReason());
+  }
 
   BOOST_FOREACH(const Comment& comment, comments) {
     feedComment(comment);