Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-18281

COM_RESET_CONNECTION change the connection encoding

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.2.21, 10.3.12
    • Fix Version/s: 10.2.22, 10.3.13
    • Component/s: Protocol
    • Labels:
      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

        Attachments

          Activity

            People

            • Assignee:
              wlad Vladislav Vaintroub
              Reporter:
              diego dupin Diego Dupin
            • Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: