diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-07-14 14:54:51 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2024-07-14 14:54:51 +0200 |
commit | d4998bd04a27237aba635401d5aff0d7aafa12e5 (patch) | |
tree | bd08590de0ff0aec6e3383d402afe7cc3ae78861 /src/server/database/Database/QueryResult.cpp | |
parent | 3313ea1fe6717313c6dc11b783bad7c89cbab8c4 (diff) |
Core/DBLayer: Add field metadata getters to query result classes
Diffstat (limited to 'src/server/database/Database/QueryResult.cpp')
-rw-r--r-- | src/server/database/Database/QueryResult.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/server/database/Database/QueryResult.cpp b/src/server/database/Database/QueryResult.cpp index 48a8e5ac608..cbb349e5803 100644 --- a/src/server/database/Database/QueryResult.cpp +++ b/src/server/database/Database/QueryResult.cpp @@ -486,12 +486,12 @@ m_metadataResult(result) return; } - m_rows.resize(uint32(m_rowCount) * m_fieldCount); + m_rows.resize(std::size_t(m_rowCount) * m_fieldCount); while (_NextRow()) { for (uint32 fIndex = 0; fIndex < m_fieldCount; ++fIndex) { - m_rows[uint32(m_rowPosition) * m_fieldCount + fIndex].SetMetadata(&m_fieldMetadata[fIndex]); + m_rows[std::size_t(m_rowPosition) * m_fieldCount + fIndex].SetMetadata(&m_fieldMetadata[fIndex]); unsigned long buffer_length = m_rBind[fIndex].buffer_length; unsigned long fetched_length = *m_rBind[fIndex].length; @@ -518,7 +518,7 @@ m_metadataResult(result) break; } - m_rows[uint32(m_rowPosition) * m_fieldCount + fIndex].SetValue( + m_rows[std::size_t(m_rowPosition) * m_fieldCount + fIndex].SetValue( (char const*)buffer, fetched_length); @@ -527,7 +527,7 @@ m_metadataResult(result) } else { - m_rows[uint32(m_rowPosition) * m_fieldCount + fIndex].SetValue( + m_rows[std::size_t(m_rowPosition) * m_fieldCount + fIndex].SetValue( nullptr, *m_rBind[fIndex].length); } @@ -552,12 +552,10 @@ PreparedResultSet::~PreparedResultSet() bool ResultSet::NextRow() { - MYSQL_ROW row; - if (!_result) return false; - row = mysql_fetch_row(_result); + MYSQL_ROW row = mysql_fetch_row(_result); if (!row) { CleanUp(); @@ -629,19 +627,31 @@ void PreparedResultSet::CleanUp() Field const& ResultSet::operator[](std::size_t index) const { - ASSERT(index < _fieldCount); + ASSERT(index < std::size_t(_fieldCount)); return _currentRow[index]; } +QueryResultFieldMetadata const& ResultSet::GetFieldMetadata(std::size_t index) const +{ + ASSERT(index < std::size_t(_fieldCount)); + return _fieldMetadata[index]; +} + Field* PreparedResultSet::Fetch() const { ASSERT(m_rowPosition < m_rowCount); - return const_cast<Field*>(&m_rows[uint32(m_rowPosition) * m_fieldCount]); + return const_cast<Field*>(&m_rows[std::size_t(m_rowPosition) * m_fieldCount]); } Field const& PreparedResultSet::operator[](std::size_t index) const { ASSERT(m_rowPosition < m_rowCount); - ASSERT(index < m_fieldCount); - return m_rows[uint32(m_rowPosition) * m_fieldCount + index]; + ASSERT(index < std::size_t(m_fieldCount)); + return m_rows[std::size_t(m_rowPosition) * m_fieldCount + index]; +} + +QueryResultFieldMetadata const& PreparedResultSet::GetFieldMetadata(std::size_t index) const +{ + ASSERT(index < std::size_t(m_fieldCount)); + return m_fieldMetadata[index]; } |