Bug #97633 COM_RESET_CONNECTION change the connection encoding
Submitted: 14 Nov 2019 10:54 Modified: 19 Nov 2019 10:16
Reporter: diego dupin (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8 OS:Any
Assigned to: CPU Architecture:Any
Tags: reset charset

[14 Nov 2019 10:54] diego dupin
Description:
After using COM_RESET_CONNECTION, connection encoding is changed to server default charset, not initial connection charset.

Connection charset is set with Client Handshake Response "client character collation" field.

This value has to be stored and restored on COM_RESET_CONNECTION

How to repeat:
connect with a charset different than server. 
reset connection.
charset will now be default server charset
[14 Nov 2019 13:26] MySQL Verification Team
Hello Mr. q,

Thank you for your bug report.

However, we do not think that this is a bug.

COM_RESET_CONNECTION resets server side of the connection to its default state. Hence, when reconnection is automatically done, you get a default client character set for that connection from the server. This is described in our documentation for the C API.

Then, you have to use one of the commands, like "SET NAMES ...." to change the client-side collation.

Do note that  there is a number of character sets that can not be used on the client side, as per our Reference Manual. Check whether your client character set is among those .....

Not a bug.
[19 Nov 2019 10:16] diego dupin
I don't see why this would not be a bug. 
This corresponds to https://jira.mariadb.org/browse/MDEV-18281 in MariaDB

See https://dev.mysql.com/doc/dev/mysql-server/8.0.11/page_protocol_connection_phase_packets_p... charset is indicate in Protocol::HandshakeResponse41 with 	character_set.

Most of connectors set charset with that field, so establishing a connection is 2 exchanges (server greetings, client response) without needing another 2 exchanges for a "SET NAMES" query.  

But this charset when using COM_RESET_CONNECTION is then changed to another charset that is server default charset that might be totally different.
[19 Nov 2019 13:35] MySQL Verification Team
Hi,

First of all, we do not follow what other RDBMS vendors are doing. We go our way.

Also , there is a very, very easy workaround for what you want, which means setting a desired character set for client or connection or results, immediately after this command. This is a reason why this could not be even a feature request.  This could be a feature request for some higher-level connector, like Connector/C++ and then only for some future version.