-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix](prepared statement) fix protocol with TIME datatype (#47389)
This pull request adds functionality to encode time values into MySQL binary protocol format with microsecond precision and includes corresponding test cases. The changes primarily involve adding a new function for encoding time and updating the `push_time` and `push_timev2` methods in the `MysqlRowBuffer` class to use this new function. ### Encoding time into MySQL binary protocol format: * [`be/src/util/mysql_row_buffer.cpp`](diffhunk://#diff-181b7a490933fd9d3f8a00c97852d8fa17ab34694b1683ffd762e0f595a7c4fbR364-R433): Added the `encode_binary_timev2` function to encode time into MySQL binary protocol format with support for microsecond precision. The function handles time values within the range of '-838:59:59' to '838:59:59' and adjusts the precision based on the provided scale. ### Updates to `MysqlRowBuffer` class: * [`be/src/util/mysql_row_buffer.cpp`](diffhunk://#diff-181b7a490933fd9d3f8a00c97852d8fa17ab34694b1683ffd762e0f595a7c4fbR364-R433): Updated the `push_time` method to throw an exception for unsupported time types in binary protocol. * [`be/src/util/mysql_row_buffer.cpp`](diffhunk://#diff-181b7a490933fd9d3f8a00c97852d8fa17ab34694b1683ffd762e0f595a7c4fbL382-R451): Modified the `push_timev2` method to use the new `encode_binary_timev2` function, adjusting the buffer size and appending the encoded time. ### Test cases: * [`be/test/util/mysql_row_buffer_test.cpp`](diffhunk://#diff-1feab58caea3546e0e6fda52bff2fbd5f60f7cafcef8f891be83b0a2f74a93ebR118-R133): Added a new test case `TestBinaryTimeCompressedEncoding` to verify the correct encoding of time values in various scenarios, including zero time, time without microseconds, time with microseconds, and negative time values.
- Loading branch information
Showing
2 changed files
with
211 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters