Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2.21, 10.3.12
-
None
Description
When creating a connection, a connector indicates the charset to use for communication in initial handshake packet.
After a COM_RESET_CONNECTION connection charset is reinitialized not to the one indicated in initial handshake packet, but to another value, character_set_server.
example to reproduced :
public void test() throws SQLException { |
try (Connection connection = DriverManager.getConnection("jdbc:mariadb://localhost:3306/testj?user=root&useResetConnection=true")) { |
Statement stmt = connection.createStatement();
|
showCharacterVariables(stmt);
|
((MariaDbConnection)connection).reset();
|
|
showCharacterVariables(stmt);
|
}
|
}
|
|
public void showCharacterVariables(Statement stmt) throws SQLException { |
ResultSet rs = stmt.executeQuery("SHOW VARIABLES LIKE 'character_%'"); |
while (rs.next()) { |
System.out.println(rs.getString(1) + " " + rs.getString(2)); |
}
|
System.out.println("----------------------------------------------"); |
}
|
|
returns :
character_set_client utf8mb4
|
character_set_connection utf8mb4
|
character_set_database latin1
|
character_set_filesystem binary
|
character_set_results utf8mb4
|
character_set_server latin1
|
character_set_system utf8
|
character_sets_dir c:\Program Files\MariaDB 10.2\share\charsets\
|
----------------------------------------------
|
character_set_client latin1
|
character_set_connection latin1
|
character_set_database latin1
|
character_set_filesystem binary
|
character_set_results latin1
|
character_set_server utf8
|
character_set_system utf8
|
character_sets_dir c:\Program Files\MariaDB 10.2\share\charsets\
|
----------------------------------------------
|
Initial charset transmitted during initial-handshake-packet must be saved and reapplyed, not character_set_server value.
another part that is less important, but resetting connection normally would reset the database to the one set in the same handshake packet