Skip to content

Fix issue #4841#4842

Merged
renecannao merged 1 commit intov3.0from
v3.0_collation_255
Mar 9, 2025
Merged

Fix issue #4841#4842
renecannao merged 1 commit intov3.0from
v3.0_collation_255

Conversation

@renecannao
Copy link
Contributor

Incorrectly attempt to use a collation with id larger than 255 during backend handshake

Problem:
When creating a backend connection, if the frontend connection has configured a collation with id larger than 255 (for example using SET NAMES utf8mb4 COLLATE utf8mb4_0900_as_ci; , ProxySQL may try to create a new connection using such collation. The problem is that at protocol level, during handshake only 1 byte can be used to configure the collation. That means that if ProxySQL sets a collation greater than 255 , only the less significant byte is used. Therefore even if ProxySQL believes that the backend connection will use the specified collation, mysql_real_connect() is using a different collation. For example, using collation 305 will lead to use collation 49 (305-256).

Solution:
When a collation id greater than 255 is detected, the default collation for that character set is used. ProxySQL will later issue a SET NAMES ... COLLATE to address the mismatch.

Incorrectly attempt to use a collation with id larger than 255 during backend handshake

Problem:
When creating a backend connection, if the frontend connection has configured a collation with id larger than 255 (for example using SET NAMES utf8mb4 COLLATE utf8mb4_0900_as_ci; , ProxySQL may try to create a new connection using such collation.
The problem is that at protocol level, during handshake only 1 byte can be used to configure the collation.
That means that if ProxySQL sets a collation greater than 255 , only the less significant byte is used.
Therefore even if ProxySQL believes that the backend connection will use the specified collation, mysql_real_connect() is using a different collation. For example, using collation 305 will lead to use collation 49 (305-256).

Solution:
When a collation id greater than 255 is detected, the default collation for that character set is used.
ProxySQL will later issue a SET NAMES ... COLLATE to address the mismatch.
@renecannao renecannao merged commit f27aa6f into v3.0 Mar 9, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant