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

Fix max_allowed_packet math #203

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions contrib/ruby/test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,12 @@ def test_configured_max_packet_below_server

assert_equal "trilogy_query_send: TRILOGY_MAX_PACKET_EXCEEDED", exception.message

exception = assert_raises Trilogy::QueryError do
client.query query_for_target_packet_size(32 * 1024 * 1024 + 1)
end

assert_equal "trilogy_query_send: TRILOGY_MAX_PACKET_EXCEEDED", exception.message

assert client.ping
ensure
ensure_closed client
Expand Down
2 changes: 1 addition & 1 deletion src/builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int trilogy_builder_write_buffer(trilogy_builder_t *builder, const void *data, s

size_t fragment_remaining = TRILOGY_MAX_PACKET_LEN - builder->fragment_length;

if (builder->packet_length >= builder->packet_max_length - len) {
if (builder->packet_length + len >= builder->packet_max_length) {
return TRILOGY_MAX_PACKET_EXCEEDED;
}

Expand Down