]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Turn Comment.qname into a DNSName
authorChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Sun, 21 Feb 2016 22:15:17 +0000 (23:15 +0100)
committerChristian Hofstaedtler <christian.hofstaedtler@deduktiva.com>
Sun, 21 Feb 2016 22:15:59 +0000 (23:15 +0100)
pdns/backends/gsql/gsqlbackend.cc
pdns/comment.hh
pdns/ws-auth.cc

index c41670ce50fae829924895f0b166b24d325d23da..e6322e789f21afe2c6eef99f4cc2214f2088ce1e 100644 (file)
@@ -1495,25 +1495,30 @@ bool GSQLBackend::getComment(Comment& comment)
 {
   SSqlStatement::row_t row;
 
-  if (!d_query_stmt->hasNextRow()) {
+  for(;;) {
+    if (!d_query_stmt->hasNextRow()) {
+      try {
+        d_query_stmt->reset();
+      } catch(SSqlException &e) {
+        throw DBException("GSQLBackend comment get: "+e.txtReason());
+      }
+      d_query_stmt = NULL;
+      return false;
+    }
+
     try {
-      d_query_stmt->reset();
+      d_query_stmt->nextRow(row);
+      ASSERT_ROW_COLUMNS(d_query_name, row, 6);
     } catch(SSqlException &e) {
       throw DBException("GSQLBackend comment get: "+e.txtReason());
     }
-    d_query_stmt = NULL;
-    return false;
-  }
-
-  try {
-    d_query_stmt->nextRow(row);
-    ASSERT_ROW_COLUMNS(d_query_name, row, 6);
-  } catch(SSqlException &e) {
-    throw DBException("GSQLBackend comment get: "+e.txtReason());
+    try {
+      extractComment(row, comment);
+    } catch (...) {
+      continue;
+    }
+    return true;
   }
-  // domain_id,name,type,modified_at,account,comment
-  extractComment(row, comment);
-  return true;
 }
 
 void GSQLBackend::feedComment(const Comment& comment)
@@ -1521,7 +1526,7 @@ void GSQLBackend::feedComment(const Comment& comment)
   try {
     d_InsertCommentQuery_stmt->
       bind("domain_id",comment.domain_id)->
-      bind("qname",toLower(comment.qname))->
+      bind("qname",comment.qname)->
       bind("qtype",comment.qtype.getName())->
       bind("modified_at",comment.modified_at)->
       bind("account",comment.account)->
@@ -1592,6 +1597,7 @@ string GSQLBackend::pattern2SQLPattern(const string &pattern)
 
 bool GSQLBackend::searchRecords(const string &pattern, int maxResults, vector<DNSResourceRecord>& result)
 {
+  d_qname.clear();
   try {
     string escaped_pattern = pattern2SQLPattern(pattern);
 
@@ -1690,12 +1696,12 @@ void GSQLBackend::extractRecord(const SSqlStatement::row_t& row, DNSResourceReco
 
 void GSQLBackend::extractComment(const SSqlStatement::row_t& row, Comment& comment)
 {
- comment.domain_id = pdns_stou(row[0]);
comment.qname = row[1];
- comment.qtype = row[2];
- comment.modified_at = pdns_stou(row[3]);
- comment.account = row[4];
- comment.content = row[5];
 comment.domain_id = pdns_stou(row[0]);
 comment.qname = DNSName(row[1]);
 comment.qtype = row[2];
 comment.modified_at = pdns_stou(row[3]);
 comment.account = row[4];
 comment.content = row[5];
 }
 
 bool GSQLBackend::isOurDomain(const DNSName *zone, int domain_id) {
index 2fd3e5ea99c654af5171b5925c3011d1eaf562b9..06692bbc752017f5f68b8b7cfd9f47d9c0d5dcfa 100644 (file)
@@ -33,7 +33,7 @@ public:
   ~Comment() {};
 
   // data
-  string qname; //!< the name of the associated RRset, for example: www.powerdns.com
+  DNSName qname; //!< the name of the associated RRset, for example: www.powerdns.com
   time_t modified_at;
   string account; //!< account last updating this comment
   string content; //!< The actual comment. Example: blah blah
index 8d886877553d405b1720a9aa95212aca4fe9914c..e69f470244aaea3c39a1f3eb6e571f77f14e362d 100644 (file)
@@ -359,7 +359,7 @@ static void fillZone(const DNSName& zonename, HttpResponse* resp) {
   di.backend->listComments(di.id);
   while(di.backend->getComment(comment)) {
     comments.push_back(Json::object {
-      { "name", comment.qname },
+      { "name", comment.qname.toString() },
       { "type", comment.qtype.getName() },
       { "modified_at", (double)comment.modified_at },
       { "account", comment.account },
@@ -1068,7 +1068,7 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) {
     {
       auto object = Json::object {
         { "object_type", "comment" },
-        { "name", c.qname },
+        { "name", c.qname.toString() },
         { "content", c.content }
       };
       if ((val = zoneIdZone.find(c.domain_id)) != zoneIdZone.end()) {