Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-4489

PHP program reports different collation_connection when connecting via Maxscale

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 2.5.24, 6.4.5, 22.08.4
    • 2.5.25, 6.4.6, 22.08.5
    • Core
    • None

    Description

      Having a server with

      [server]
      character-set-server  = utf8mb3
      collation-server      = utf8mb3_swedish_ci
      

      the command line client, return "utf8mb3_general_ci" as result of

      SHOW VARIABLES LIKE 'collation_connection';

      both when connecting to the MariaDB server directly, and when connecting via Maxscale.

      A PHP program on the other hand also returns "utf8mb3_general_ci" when connecting via Maxscale, but "utf8mb3_swedish_ci" when connecting to MariaDB server directly.

      This breaks PHP applications that do not explicitly set client character set / collation.

      PHP test code I used:

      <?php
       
      function test($host) 
      {
        $mysqli = new mysqli($host,"vagrant","Secret23!");
        if ($mysqli -> connect_errno) {
          echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
          exit();
        }
        echo "Host: $host\n";
        if ($result = $mysqli -> query("SHOW VARIABLES LIKE 'collation_connection'")) {
          while($row = mysqli_fetch_assoc($result)){
            print_r($row);
          }
          $result -> free_result();
        }
        echo "\n";
        $mysqli -> close();
      }
       
      test("master");
      test("maxscale");
      ?>
      

      Note that PHP does not use a bundled version of libmysqlclient anymore by default, but its own "mysqlnd" implementation of the client protocol.

      Attachments

        Activity

          People

            markus makela markus makela
            hholzgra Hartmut Holzgraefe
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.