opensrv
opensrv copied to clipboard
fix: write binary as hex strings in mysql text protocol
I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/
Summary
Currently the text protocol write binary value directly into the packet, thus the client would get the original binary values and display it like this:
But actually the mysql client display the binary value as hex strings (MySQL (client v8.4.0, server v9.0.1)):
Through the client source code it only parse binary values as hex strings when using binary charset:
// See https://github.com/mysql/mysql-server/blob/596f0d238489a9cf9f43ce1ff905984f58d227b6/client/mysql.cc
// L3916-L3918 and L4033-L4034
tatic bool is_binary_field(MYSQL_FIELD *field) {
return (
(field->charsetnr == 63) &&
// ...
// when write results
if (opt_binhex && is_binary_field(field))
print_as_hex(PAGER, cur[off], lengths[off], field_max_length);
So I wonder if it's proper to directly write hex strings when using text protocol :)