]> granicus.if.org Git - pdns/commitdiff
code cleanup gmysqlbackend
authorKees Monshouwer <mind04@monshouwer.org>
Sun, 10 Nov 2013 20:14:23 +0000 (21:14 +0100)
committermind04 <mind04@monshouwer.org>
Wed, 13 Nov 2013 11:06:02 +0000 (12:06 +0100)
modules/gmysqlbackend/smysql.cc
modules/gmysqlbackend/smysql.hh

index 84b8c17d9680947d5f7cb4571bb454f03b517b6b..8b8682408dc51d838facee04390a04a8f9b8d39d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright 2001 Netherlabs BV, bert.hubert@netherlabs.nl. See LICENSE 
+/* Copyright 2001 Netherlabs BV, bert.hubert@netherlabs.nl. See LICENSE
    for more information.
    $Id$  */
 #include "smysql.hh"
@@ -13,7 +13,7 @@
 bool SMySQL::s_dolog;
 pthread_mutex_t SMySQL::s_myinitlock = PTHREAD_MUTEX_INITIALIZER;
 
-SMySQL::SMySQL(const string &database, const string &host, uint16_t port, const string &msocket, const string &user, 
+SMySQL::SMySQL(const string &database, const string &host, uint16_t port, const string &msocket, const string &user,
                const string &password, const string &group, bool setIsolation)
 {
   int retry=1;
@@ -90,10 +90,9 @@ int SMySQL::doQuery(const string &query)
     L<<Logger::Warning<<"Query: "<<query<<endl;
 
   int err;
-  if((err=mysql_query(&d_db,query.c_str()))) 
+  if((err=mysql_query(&d_db,query.c_str())))
     throw sPerrorException("Failed to execute mysql_query, perhaps connection died? Err="+itoa(err));
 
-
   return 0;
 }
 
@@ -112,7 +111,7 @@ int SMySQL::doQuery(const string &query, result_t &result)
 bool SMySQL::getRow(row_t &row)
 {
   row.clear();
-  if(!d_rres) 
+  if(!d_rres)
     if(!(d_rres = mysql_use_result(&d_db)))
       throw sPerrorException("Failed on mysql_use_result");
 
@@ -123,7 +122,7 @@ bool SMySQL::getRow(row_t &row)
       row.push_back(rrow[i] ?: "");
     return true;
   }
-  mysql_free_result(d_rres);  
+  mysql_free_result(d_rres);
 
   while (mysql_next_result(&d_db) == 0) {
     if ((d_rres = mysql_use_result(&d_db))) {
@@ -146,30 +145,3 @@ string SMySQL::escape(const string &name)
   }
   return a;
 }
-
-
-#if 0
-int main()
-{
-  try {
-    SMySQL s("kkfnetmail","127.0.0.1","readonly");
-    SSql::result_t juh;
-    
-    int num=s.doQuery("select *, from mboxes", juh);
-    cout<<num<<" responses"<<endl;
-    
-    for(int i=0;i<num;i++) {
-      const SSql::row_t &row=juh[i];
-
-      for(SSql::row_t::const_iterator j=row.begin();j!=row.end();++j)
-        cout <<"'"<< *j<<"', ";
-      cout<<endl;
-    }
-  }
-  catch(SSqlException &e) {
-    cerr<<e.txtReason()<<endl;
-  }
-}
-
-
-#endif
index 24b69b31dc64cec24c8462f14ef18dd88085a5a1..6d798a388de12f3715bf3f1608ecc3206c15660d 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <mysql.h>
 #include "pdns/backends/gsql/ssql.hh"
-#include "pdns/utility.hh" 
+#include "pdns/utility.hh"
 
 class SMySQL : public SSql
 {
@@ -17,13 +17,13 @@ public:
          bool setIsolation=false);
 
   ~SMySQL();
-  
+
   SSqlException sPerrorException(const string &reason);
   int doQuery(const string &query, result_t &result);
   int doQuery(const string &query);
   int doCommand(const string &query);
   bool getRow(row_t &row);
-  string escape(const string &str);    
+  string escape(const string &str);
   void setLog(bool state);
 private:
   MYSQL d_db;
@@ -31,5 +31,5 @@ private:
   static bool s_dolog;
   static pthread_mutex_t s_myinitlock;
 };
-      
+
 #endif /* SSMYSQL_HH */