class SQLhost
{
public:
- std::string id; /* Database handle id */
- std::string host; /* Database server hostname */
+ std::string id; /* Database handle id */
+ std::string host; /* Database server hostname */
unsigned int port; /* Database server port */
- std::string name; /* Database name */
- std::string user; /* Database username */
- std::string pass; /* Database password */
- bool ssl; /* If we should require SSL */
+ std::string name; /* Database name */
+ std::string user; /* Database username */
+ std::string pass; /* Database password */
+ bool ssl; /* If we should require SSL */
SQLhost()
{
}
};
+/** Used to resolve sql server hostnames
+ */
class SQLresolver : public Resolver
{
private:
ModulePgSQL* mod;
public:
SQLresolver(ModulePgSQL* m, InspIRCd* Instance, const SQLhost& hi)
- : Resolver(Instance, hi.host, DNS_QUERY_FORWARD), host(hi), mod(m)
+ : Resolver(Instance, hi.host, DNS_QUERY_FORWARD, (Module*)m), host(hi), mod(m)
{
}
sqlsuccess = new char[strlen(SQLSUCCESS)+1];
- strcpy(sqlsuccess, SQLSUCCESS);
+ strlcpy(sqlsuccess, SQLSUCCESS, strlen(SQLSUCCESS)+1);
OnRehash("");
}
virtual Version GetVersion()
{
- return Version(1, 0, 0, 0, VF_VENDOR|VF_SERVICEPROVIDER);
+ return Version(1, 1, 0, 0, VF_VENDOR|VF_SERVICEPROVIDER, API_VERSION);
}
virtual ~ModulePgSQL()
{
/* ..and the result */
PgSQLresult reply(us, to, query.id, result);
+
+ /* Fix by brain, make sure the original query gets sent back in the reply */
+ reply.query = query.query.q;
Instance->Log(DEBUG, "Got result, status code: %s; error message: %s", PQresStatus(PQresultStatus(result)), PQresultErrorMessage(result));
#ifdef PGSQL_HAS_ESCAPECONN
len = PQescapeStringConn(sql, queryend, req.query.p.front().c_str(), req.query.p.front().length(), &error);
#else
- len = PQescapeStringConn(queryend, req.query.p.front().c_str(), req.query.p.front().length());
- error = 0;
+ len = PQescapeString (queryend, req.query.p.front().c_str(), req.query.p.front().length());
#endif
if(error)
{
{
Instance->Log(DEBUG, "Dispatched query successfully");
qinprog = true;
- DELETE(query);
+ delete[] query;
return SQLerror();
}
else
{
Instance->Log(DEBUG, "Failed to dispatch query: %s", PQerrorMessage(sql));
- DELETE(query);
+ delete[] query;
return SQLerror(QSEND_FAIL, PQerrorMessage(sql));
}
}