-/* 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"
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;
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;
}
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");
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))) {
}
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
#include <mysql.h>
#include "pdns/backends/gsql/ssql.hh"
-#include "pdns/utility.hh"
+#include "pdns/utility.hh"
class SMySQL : public SSql
{
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;
static bool s_dolog;
static pthread_mutex_t s_myinitlock;
};
-
+
#endif /* SSMYSQL_HH */