248 :
255{
257 return;
258
259 if (
m_stmt->bind_result_done)
260 {
261 delete[]
m_stmt->bind->length;
262 delete[]
m_stmt->bind->is_null;
263 }
264
266
267
268
269
271 unsigned long* m_length =
new unsigned long[
m_fieldCount];
272
275 memset(m_length, 0,
sizeof(
unsigned long) *
m_fieldCount);
276
277
278 if (mysql_stmt_store_result(
m_stmt))
279 {
280 LOG_WARN(
"sql.sql",
"{}:mysql_stmt_store_result, cannot bind result from MySQL server. Error: {}", __FUNCTION__, mysql_stmt_error(
m_stmt));
282 delete[] m_isNull;
283 delete[] m_length;
284 return;
285 }
286
288
289
292 std::size_t rowSize = 0;
293
295 {
297 rowSize += size;
298
300
301 m_rBind[i].buffer_type = field[i].type;
302 m_rBind[i].buffer_length = size;
303 m_rBind[i].length = &m_length[i];
304 m_rBind[i].is_null = &m_isNull[i];
306 m_rBind[i].is_unsigned = field[i].flags & UNSIGNED_FLAG;
307 }
308
309 char* dataBuffer =
new char[rowSize *
m_rowCount];
311 {
312 m_rBind[i].buffer = dataBuffer + offset;
313 offset +=
m_rBind[i].buffer_length;
314 }
315
316
318 {
319 LOG_WARN(
"sql.sql",
"{}:mysql_stmt_bind_result, cannot bind result from MySQL server. Error: {}", __FUNCTION__, mysql_stmt_error(
m_stmt));
320 mysql_stmt_free_result(
m_stmt);
322 delete[] m_isNull;
323 delete[] m_length;
324 return;
325 }
326
328
330 {
332 {
334
335 unsigned long buffer_length =
m_rBind[fIndex].buffer_length;
336 unsigned long fetched_length = *
m_rBind[fIndex].length;
338 {
339 void* buffer =
m_stmt->bind[fIndex].buffer;
340 switch (
m_rBind[fIndex].buffer_type)
341 {
342 case MYSQL_TYPE_TINY_BLOB:
343 case MYSQL_TYPE_MEDIUM_BLOB:
344 case MYSQL_TYPE_LONG_BLOB:
345 case MYSQL_TYPE_BLOB:
346 case MYSQL_TYPE_STRING:
347 case MYSQL_TYPE_VAR_STRING:
348
349
350
351
353 if (fetched_length < buffer_length)
354 *((char*)buffer + fetched_length) = '\0';
355 break;
356 default:
357 break;
358 }
359
361
362
363 m_stmt->bind[fIndex].buffer = (
char*)buffer + rowSize;
364 }
365 else
366 {
368 }
369 }
370
372 }
373
375
377 mysql_stmt_free_result(
m_stmt);
378}
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
std::uint32_t uint32
Definition: Define.h:107
std::remove_pointer_t< decltype(std::declval< MYSQL_BIND >().is_null)> MySQLBool
Definition: MySQLHacks.h:32
void InitializeDatabaseFieldMetadata(QueryResultFieldMetadata *meta, MySQLField const *field, uint32 fieldIndex)
Definition: QueryResult.cpp:155
static uint32 SizeForType(MYSQL_FIELD *field)
Definition: QueryResult.cpp:27
Definition: MySQLHacks.h:26
Definition: MySQLHacks.h:27
std::vector< QueryResultFieldMetadata > m_fieldMetadata
Definition: QueryResult.h:131
MySQLStmt * m_stmt
Definition: QueryResult.h:139
uint64 m_rowPosition
Definition: QueryResult.h:134
void CleanUp()
Definition: QueryResult.cpp:419
uint64 m_rowCount
Definition: QueryResult.h:133
bool _NextRow()
Definition: QueryResult.cpp:395
MySQLBind * m_rBind
Definition: QueryResult.h:138
uint32 m_fieldCount
Definition: QueryResult.h:135
std::vector< Field > m_rows
Definition: QueryResult.h:132
MySQLResult * m_metadataResult
Field metadata, returned by mysql_stmt_result_metadata.
Definition: QueryResult.h:140