Fixed bug with ErrorBuffer being overwritten on non query requests

This commit is contained in:
Arthur Ice 2014-08-11 13:55:25 -07:00
parent 321cf17eac
commit f1b8908c9a

View File

@ -10,35 +10,24 @@ MySQLRequestResult::MySQLRequestResult()
MySQLRequestResult::MySQLRequestResult(MYSQL_RES* result, uint32 rowsAffected, uint32 rowCount, uint32 columnCount, uint32 lastInsertedID, uint32 errorNumber, char *errorBuffer) MySQLRequestResult::MySQLRequestResult(MYSQL_RES* result, uint32 rowsAffected, uint32 rowCount, uint32 columnCount, uint32 lastInsertedID, uint32 errorNumber, char *errorBuffer)
: m_CurrentRow(result), m_OneBeyondRow() : m_CurrentRow(result), m_OneBeyondRow()
{ {
if (errorBuffer != nullptr)
m_Success = false;
else if (errorBuffer == nullptr && result == nullptr)
{
m_Success = false;
#ifdef _EQDEBUG
std::cout << "DB Query Error: No Result" << std::endl;
#endif
m_ErrorNumber = UINT_MAX;
m_ErrorBuffer = new char[MYSQL_ERRMSG_SIZE];
strcpy(m_ErrorBuffer, "DBcore::RunQuery: No Result");
}
else
m_Success = true;
m_Result = result; m_Result = result;
m_ErrorBuffer = errorBuffer;
m_RowsAffected = rowsAffected; m_RowsAffected = rowsAffected;
m_RowCount = rowCount; m_RowCount = rowCount;
m_ColumnCount = columnCount; m_ColumnCount = columnCount;
m_LastInsertedID = lastInsertedID;
// If we actually need the column length / fields it will be // If we actually need the column length / fields it will be
// requested at that time, no need to pull it in just to cache it. // requested at that time, no need to pull it in just to cache it.
// Normal usage would have it as nullptr most likely anyways. // Normal usage would have it as nullptr most likely anyways.
m_ColumnLengths = nullptr; m_ColumnLengths = nullptr;
m_Fields = nullptr; m_Fields = nullptr;
m_LastInsertedID = lastInsertedID;
if (errorBuffer != nullptr)
m_Success = false;
m_Success = true;
m_ErrorNumber = errorNumber; m_ErrorNumber = errorNumber;
m_ErrorBuffer = errorBuffer;
} }
void MySQLRequestResult::FreeInternals() void MySQLRequestResult::FreeInternals()