Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update charset/collation description indicate this is 16-bits, not 8-bits. #96

Closed
wants to merge 1 commit into from

Conversation

dveeden
Copy link

@dveeden dveeden commented May 1, 2024

The collation (confusingly called charset in the code, probably because of historical reasons) is 2 bytes, not 1.

Note that the link in the description points to https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_character_set.html#a_protocol_character_set which describes Collations, not Charsets. See also the SHOW COLLATION and SHOW CHARSET output (or the corresponding I_S tables).

In the code below a H is used to format bytes for charset in struct.pack(). Also the filler has a length of 22 and not 23 as the docs incorrectly list.

filler = "x" * 22
response_payload.append(
struct.pack(
f"<IIH{filler}{len(b_username)}sx",
client_flags,
max_allowed_packet,
charset,
b_username,
)
)

# charset
if is_change_user_request:
response_payload.append(struct.pack("<H", charset))

And here utils.int2store() is used:

See also:

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
Thanks

@dveeden
Copy link
Author

dveeden commented May 1, 2024

I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Your code has been assigned to an internal queue. Please follow
bug http://bugs.mysql.com/bug.php?id=114857 for updates.
Thanks

@vaintroub
Copy link

Apparently, there is a bug in python connector, that it sends 2 bytes, not in all other connectors, and all protocol documentation :)
Server does not read 2 bytes for collation id, it reads 1, as documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants