mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-18880: Optimizer trace prints date in hexadecimal
Introduced a print_key_value function to makes sure that the trace prints data in readable format for readable characters and the rest of the characters are printed as hexadecimal.
This commit is contained in:
55
sql/field.cc
55
sql/field.cc
@ -11242,3 +11242,58 @@ bool Field::val_str_nopad(MEM_ROOT *mem_root, LEX_CSTRING *to)
|
||||
thd->variables.sql_mode= sql_mode_backup;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
void Field::print_key_value(String *out, uint32 length)
|
||||
{
|
||||
if (charset() == &my_charset_bin)
|
||||
print_key_value_binary(out, ptr, length);
|
||||
else
|
||||
val_str(out);
|
||||
}
|
||||
|
||||
|
||||
void Field_string::print_key_value(String *out, uint32 length)
|
||||
{
|
||||
if (charset() == &my_charset_bin)
|
||||
{
|
||||
size_t len= field_charset->cset->lengthsp(field_charset, (const char*) ptr, length);
|
||||
print_key_value_binary(out, ptr, static_cast<uint32>(len));
|
||||
}
|
||||
else
|
||||
{
|
||||
THD *thd= get_thd();
|
||||
sql_mode_t sql_mode_backup= thd->variables.sql_mode;
|
||||
thd->variables.sql_mode&= ~MODE_PAD_CHAR_TO_FULL_LENGTH;
|
||||
val_str(out,out);
|
||||
thd->variables.sql_mode= sql_mode_backup;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Field_varstring::print_key_value(String *out, uint32 length)
|
||||
{
|
||||
if (charset() == &my_charset_bin)
|
||||
print_key_value_binary(out, get_data(), get_length());
|
||||
else
|
||||
val_str(out,out);
|
||||
}
|
||||
|
||||
|
||||
void Field_blob::print_key_value(String *out, uint32 length)
|
||||
{
|
||||
if (charset() == &my_charset_bin)
|
||||
{
|
||||
uchar *blob;
|
||||
memcpy(&blob, ptr+packlength, sizeof(uchar*));
|
||||
print_key_value_binary(out, blob, get_length());
|
||||
}
|
||||
else
|
||||
val_str(out, out);
|
||||
}
|
||||
|
||||
|
||||
void Field::print_key_value_binary(String *out, const uchar* key, uint32 length)
|
||||
{
|
||||
out->append_semi_hex((const char*)key, length, charset());
|
||||
}
|
Reference in New Issue
Block a user