Skip to content

feat(mysql): add an option to not request CLIENT_DEPRECATE_EOF - #4524

Open
l0ng-ai wants to merge 2 commits into
transact-rs:mainfrom
l0ng-ai:mysql-deprecate-eof
Open

l0ng-ai wants to merge 2 commits into
transact-rs:mainfrom
l0ng-ai:mysql-deprecate-eof

Conversation

@l0ng-ai

@l0ng-ai l0ng-ai commented Nov 13, 2026

Copy link
Copy Markdown

Does your PR solve an issue?

fixes #4507

Adds MySqlConnectOptions::deprecate_eof(bool) (default true, so nothing changes unless it is set) and a deprecate-eof / deprecate_eof URL parameter. When it is false, the client doesn't request CLIENT_DEPRECATE_EOF even if the server advertises it, so result sets are read with legacy EOF packets — the same opt-out mysql_async offers for proxies that advertise the capability but still send EOF packets. Not requesting a capability is always valid for the server, and no protocol parsing changes: the existing non-DEPRECATE_EOF path (used for servers that don't advertise it) handles the rest.

Tests:

  • options::parse::it_parses_deprecate_eof: the URL parameter, the default, and the round trip through build_url.
  • tests/mysql/mysql.rs::it_reads_result_sets_without_deprecate_eof: connects with deprecate_eof(false) and reads a multi-row result, a multi-statement result and a prepared statement. Run locally against MySQL 8.4 and 5.6 (Docker).
  • Against Docker mysql:5.6 behind a TCP proxy that sets bit 24 in the greeting (the case in MySQL: option to not request CLIENT_DEPRECATE_EOF for servers that advertise it but send legacy EOF packets #4507), every query fails with OK_Packet too short: … got 2 by default and works with deprecate_eof(false).

Is this a breaking change?

No. A new option whose default keeps the current behaviour; MySqlConnectOptions fields are pub(crate), so adding one doesn't affect users.

Some proxies and servers (e.g. Aliyun RDS for MySQL 5.6) advertise
CLIENT_DEPRECATE_EOF but still end result sets with legacy EOF packets, so every
query fails with "OK_Packet too short". MySqlConnectOptions::deprecate_eof(false)
connects without requesting the capability, like mysql_async's option of the same
name. The default is unchanged.

Closes transact-rs#4507
l0ng-ai added a commit to l0ng-ai/openidea that referenced this pull request Nov 13, 2026
…but send EOF packets (#3030)

Some servers and proxies (Aliyun RDS for MySQL 5.6) advertise CLIENT_DEPRECATE_EOF but still end result sets with legacy EOF packets; sqlx requested every advertised capability, so every query failed with "OK_Packet too short". sqlx now comes from l0ng-ai/sqlx at a rev adding MySqlConnectOptions::deprecate_eof (proposed upstream as transact-rs/sqlx#4524), and opening a MySQL pool retries once without the capability when the first connection fails with that error.

Fixes #1053
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.

MySQL: option to not request CLIENT_DEPRECATE_EOF for servers that advertise it but send legacy EOF packets

1 participant