aboutsummaryrefslogtreecommitdiff
path: root/src/server/database/Database/QueryResult.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2019-11-01 16:21:14 +0100
committerShauren <shauren.trinity@gmail.com>2019-11-01 16:21:14 +0100
commitc3a9d56b56b665133707f587ecb1bd1c272f6911 (patch)
tree02dfce1fa605569e3212fbe8804125d55957d7bf /src/server/database/Database/QueryResult.cpp
parent2072258ef44e89e30256d529686ae2b8dc2b5f0d (diff)
Core/DBLayer: Support using mysql 8
Diffstat (limited to 'src/server/database/Database/QueryResult.cpp')
-rw-r--r--src/server/database/Database/QueryResult.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/server/database/Database/QueryResult.cpp b/src/server/database/Database/QueryResult.cpp
index 0e76a7807a4..4f381f8449b 100644
--- a/src/server/database/Database/QueryResult.cpp
+++ b/src/server/database/Database/QueryResult.cpp
@@ -20,10 +20,8 @@
#include "Errors.h"
#include "Field.h"
#include "Log.h"
-#ifdef _WIN32 // hack for broken mysql.h not including the correct winsock header for SOCKET definition, fixed in 5.7
-#include <winsock2.h>
-#endif
-#include <mysql.h>
+#include "MySQLHacks.h"
+#include "MySQLWorkaround.h"
static uint32 SizeForType(MYSQL_FIELD* field)
{
@@ -119,7 +117,7 @@ DatabaseFieldTypes MysqlTypeToFieldType(enum_field_types type)
return DatabaseFieldTypes::Null;
}
-ResultSet::ResultSet(MYSQL_RES *result, MYSQL_FIELD *fields, uint64 rowCount, uint32 fieldCount) :
+ResultSet::ResultSet(MySQLResult* result, MySQLField* fields, uint64 rowCount, uint32 fieldCount) :
_rowCount(rowCount),
_fieldCount(fieldCount),
_result(result),
@@ -132,7 +130,7 @@ _fields(fields)
#endif
}
-PreparedResultSet::PreparedResultSet(MYSQL_STMT* stmt, MYSQL_RES *result, uint64 rowCount, uint32 fieldCount) :
+PreparedResultSet::PreparedResultSet(MySQLStmt* stmt, MySQLResult* result, uint64 rowCount, uint32 fieldCount) :
m_rowCount(rowCount),
m_rowPosition(0),
m_fieldCount(fieldCount),
@@ -149,16 +147,16 @@ m_metadataResult(result)
delete[] m_stmt->bind->is_null;
}
- m_rBind = new MYSQL_BIND[m_fieldCount];
+ m_rBind = new MySQLBind[m_fieldCount];
//- for future readers wondering where the fuck this is freed - mysql_stmt_bind_result moves pointers to these
// from m_rBind to m_stmt->bind and it is later freed by the `if (m_stmt->bind_result_done)` block just above here
// MYSQL_STMT lifetime is equal to connection lifetime
- my_bool* m_isNull = new my_bool[m_fieldCount];
+ MySQLBool* m_isNull = new MySQLBool[m_fieldCount];
unsigned long* m_length = new unsigned long[m_fieldCount];
- memset(m_isNull, 0, sizeof(my_bool) * m_fieldCount);
- memset(m_rBind, 0, sizeof(MYSQL_BIND) * m_fieldCount);
+ memset(m_isNull, 0, sizeof(MySQLBool) * m_fieldCount);
+ memset(m_rBind, 0, sizeof(MySQLBind) * m_fieldCount);
memset(m_length, 0, sizeof(unsigned long) * m_fieldCount);
//- This is where we store the (entire) resultset
@@ -174,7 +172,7 @@ m_metadataResult(result)
m_rowCount = mysql_stmt_num_rows(m_stmt);
//- This is where we prepare the buffer based on metadata
- MYSQL_FIELD* field = mysql_fetch_fields(m_metadataResult);
+ MySQLField* field = reinterpret_cast<MySQLField*>(mysql_fetch_fields(m_metadataResult));
std::size_t rowSize = 0;
for (uint32 i = 0; i < m_fieldCount; ++i)
{