Okay, I found a cosmetic error, as I interpreted the return value of RunQuery() wrong. RunQuery() returns true when successful, so we need to edit a line:
Code:
bool DBcore::RunQuery(const char* query, int32 querylen, char* errbuf, MYSQL_RES** result, int32* affected_rows, int32* last_insert_id, int32* errnum, bool retry) {
_CP(DBcore_RunQuery);
if (errnum)
*errnum = 0;
if (errbuf)
errbuf[0] = 0;
bool ret = false;
LockMutex lock(&MDatabase);
if (pStatus != Connected)
Open();
#if DEBUG_MYSQL_QUERIES >= 1
char tmp[120];
strn0cpy(tmp, query, sizeof(tmp));
cout << "QUERY: " << tmp << endl;
#endif
if (mysql_real_query(&mysql, query, querylen)) {
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
pStatus = Error;
if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) {
if (retry) {
cout << "Database Error: Lost connection, attempting to recover...." << endl;
ret = RunQuery(query, querylen, errbuf, result, affected_rows, last_insert_id, errnum, false);
// if ( !ret ) // <- Wrong return value
if ( ret )
cout << "Reconnection to database successful." << endl;
}
else {
...
...
...