diff options
-rw-r--r-- | modules/extra/mysql.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/extra/mysql.cpp b/modules/extra/mysql.cpp index 72c026dad..aa9986db9 100644 --- a/modules/extra/mysql.cpp +++ b/modules/extra/mysql.cpp @@ -354,9 +354,14 @@ Result MySQLService::RunQuery(const Query &query) { this->Lock.lock(); - Anope::string real_query = this->BuildQuery(query); + if (!this->CheckConnection()) + { + this->Lock.unlock(); + return MySQLResult(query, query.query, mysql_error(this->sql)); + } - if (this->CheckConnection() && !mysql_real_query(this->sql, real_query.c_str(), real_query.length())) + Anope::string real_query = this->BuildQuery(query); + if (!mysql_real_query(this->sql, real_query.c_str(), real_query.length())) { MYSQL_RES *res = mysql_store_result(this->sql); unsigned int id = mysql_insert_id(this->sql); |