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

Add last_result_size to ruby connection #190

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

EvilGenius13
Copy link

Add last_result_size to ruby bindings

This PR introduces a new method last_result_size to the Trilogy gem's Ruby bindings. This method allows users to retrieve the exact byte size of the last result received from a query. The byte size includes not only the raw data but also headers, metadata, and any other protocol overhead.

Main changes:

- Added a new method `rb_trilogy_last_result_size` to surface the `conn.recv_buff_len` as a Ruby method.

Note on the test

The test checks that the last_result_size falls within a specific range (150 to 170 bytes). The reason for using a range instead of an exact value is to account for potential changes in the future. For example, changes in how headers or metadata are sent could affect the total byte size. The range provides a buffer to accommodate any of these changes.

Add a new method `last_result_size` to the Trilogy gem's Ruby bindings
that allows users to retrieve the exact byte size of the last result
received from a query.
@jhawthorn
Copy link
Member

Thanks for the PR. Could you say more about what the motivation is for this?

I think (though I'm not 100% sure) that looking at recv_buff_len will tell us the size of the last row rather than all rows (which is what I would consider the "result").

@composerinteralia
Copy link
Contributor

I think recv_buff_len is going to be however many bytes we last read, which could be multiple MySQL packets but could also be an incomplete packet.

@DerekStride
Copy link

We're trying to instrument the amount of data received over the network for each query.

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.

4 participants