[MXS-4489] PHP program reports different collation_connection when connecting via Maxscale Created: 2023-01-25  Updated: 2023-06-20  Resolved: 2023-02-20

Status: Closed
Project: MariaDB MaxScale
Component/s: Core
Affects Version/s: 2.5.24, 6.4.5, 22.08.4
Fix Version/s: 2.5.25, 6.4.6, 22.08.5

Type: Bug Priority: Major
Reporter: Hartmut Holzgraefe Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: 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.



 Comments   
Comment by markus makela [ 2023-02-20 ]

I managed to reproduce this on 22.08

Comment by markus makela [ 2023-02-20 ]

There's a bug where MaxScale always uses the default collation for the character set instead of the one defined for the server.

Generated at Thu Feb 08 04:29:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.