Improvement in prepared statements logging

In bufferTypeInfoMap , use sizeof(MYSQL_TIME) for the size of these types:
* MYSQL_TYPE_TIMESTAMP
* MYSQL_TYPE_DATE
* MYSQL_TYPE_TIME
* MYSQL_TYPE_DATETIME

Notes:
* sizeof(MYSQL_TIME) is 40
* client library may use MYSQL_TYPE_DATETIME for all of these types
pull/4922/head
René Cannaò 1 year ago
parent 05adfe5fa4
commit cbb8505ca1

@ -64,6 +64,7 @@ struct BufferTypeInfo {
// Helper lambda to convert binary data to a hex string.
auto binaryToHex = [](const MYSQL_BIND* bind, unsigned long len, std::string &out) {
std::ostringstream oss;
oss << "0x";
const unsigned char* data = reinterpret_cast<const unsigned char*>(bind->buffer);
for (unsigned long i = 0; i < len; i++) {
oss << std::setw(2) << std::setfill('0') << std::hex << (int)data[i];
@ -109,7 +110,7 @@ static const std::unordered_map<unsigned int, BufferTypeInfo> bufferTypeInfoMap
},
{ MYSQL_TYPE_TIMESTAMP,
{ "TIMESTAMP", [](const MYSQL_BIND* bind, unsigned long len, std::string &out) {
binaryToHex(bind, len, out);
binaryToHex(bind, sizeof(MYSQL_TIME), out);
}}
},
{ MYSQL_TYPE_LONGLONG,
@ -125,17 +126,17 @@ static const std::unordered_map<unsigned int, BufferTypeInfo> bufferTypeInfoMap
},
{ MYSQL_TYPE_DATE,
{ "DATE", [](const MYSQL_BIND* bind, unsigned long len, std::string &out) {
binaryToHex(bind, len, out);
binaryToHex(bind, sizeof(MYSQL_TIME), out);
}}
},
{ MYSQL_TYPE_TIME,
{ "TIME", [](const MYSQL_BIND* bind, unsigned long len, std::string &out) {
binaryToHex(bind, len, out);
binaryToHex(bind, sizeof(MYSQL_TIME), out);
}}
},
{ MYSQL_TYPE_DATETIME,
{ "DATETIME", [](const MYSQL_BIND* bind, unsigned long len, std::string &out) {
binaryToHex(bind, len, out);
binaryToHex(bind, sizeof(MYSQL_TIME), out);
}}
},
{ MYSQL_TYPE_YEAR,

Loading…
Cancel
Save