trilogy-libraries / trilogy

Trilogy is a client library for MySQL-compatible database servers, designed for performance, flexibility, and ease of embedding.
MIT License
697 stars 68 forks source link

Add `last_result_size` to ruby connection #190

Open EvilGenius13 opened 2 months ago

EvilGenius13 commented 2 months ago

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.