]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_mysql.cpp
Log SQL queries at the debug log level.
[user/henk/code/inspircd.git] / src / modules / extra / m_mysql.cpp
index 0a7d4d993ce6d78a4e5c91d7d86e15fa004bac4d..d0ccebc478550037a05a91f7d59463fe53ae3dd2 100644 (file)
@@ -68,7 +68,7 @@
  * The ircd thread then mutexes the queue once more, reads the outbound response off the head
  * of the queue, and sends it on its way to the original calling module.
  *
- * XXX: You might be asking "why doesnt he just send the response from within the worker thread?"
+ * XXX: You might be asking "why doesnt it just send the response from within the worker thread?"
  * The answer to this is simple. The majority of InspIRCd, and in fact most ircd's are not
  * threadsafe. This module is designed to be threadsafe and is careful with its use of threads,
  * however, if we were to call a module's OnRequest even from within a thread which was not the
@@ -203,7 +203,7 @@ class MySQLresult : public SQL::Result
                result.assign(colnames.begin(), colnames.end());
        }
 
-       bool HasColumn(const std::string& column, size_t& index)
+       bool HasColumn(const std::string& column, size_t& index) CXX11_OVERRIDE
        {
                for (size_t i = 0; i < colnames.size(); ++i)
                {
@@ -334,6 +334,7 @@ class SQLConnection : public SQL::Provider
 
        void Submit(SQL::Query* q, const std::string& qs) CXX11_OVERRIDE
        {
+               ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Executing MySQL query: " + qs);
                Parent()->Dispatcher->LockQueue();
                Parent()->qq.push_back(QQueueItem(q, qs, this));
                Parent()->Dispatcher->UnlockQueueWakeup();
@@ -356,10 +357,9 @@ class SQLConnection : public SQL::Provider
                                        // and one byte is the terminating null
                                        std::vector<char> buffer(parm.length() * 2 + 1);
 
-                                       // The return value of mysql_escape_string() is the length of the encoded string,
+                                       // The return value of mysql_real_escape_string() is the length of the encoded string,
                                        // not including the terminating null
-                                       unsigned long escapedsize = mysql_escape_string(&buffer[0], parm.c_str(), parm.length());
-//                                     mysql_real_escape_string(connection, queryend, paramscopy[paramnum].c_str(), paramscopy[paramnum].length());
+                                       unsigned long escapedsize = mysql_real_escape_string(connection, &buffer[0], parm.c_str(), parm.length());
                                        res.append(&buffer[0], escapedsize);
                                }
                        }
@@ -428,7 +428,7 @@ void ModuleSQL::ReadConfig(ConfigStatus& status)
        ConfigTagList tags = ServerInstance->Config->ConfTags("database");
        for(ConfigIter i = tags.first; i != tags.second; i++)
        {
-               if (i->second->getString("module", "mysql") != "mysql")
+               if (!stdalgo::string::equalsci(i->second->getString("module"), "mysql"))
                        continue;
                std::string id = i->second->getString("id");
                ConnMap::iterator curr = connections.find(id);
@@ -501,7 +501,7 @@ void ModuleSQL::OnUnloadModule(Module* mod)
 
 Version ModuleSQL::GetVersion()
 {
-       return Version("MySQL support", VF_VENDOR);
+       return Version("Provides MySQL support", VF_VENDOR);
 }
 
 void DispatcherThread::Run()