branch-2.1: [fix](mysql-buffer) fix special buffer size with nested type #45126 (#45458)

Cherry-picked from #45126

Co-authored-by: amory <wangqiannan@selectdb.com>
This commit is contained in:
github-actions[bot]
2024-12-17 17:48:10 +08:00
committed by GitHub
parent 900086667f
commit 01684ce3b1
3 changed files with 190 additions and 1 deletions

View File

@ -107,7 +107,11 @@ MysqlRowBuffer<is_binary_format>::~MysqlRowBuffer() {
template <bool is_binary_format>
void MysqlRowBuffer<is_binary_format>::open_dynamic_mode() {
if (!_dynamic_mode) {
*_pos++ = NEXT_EIGHT_BYTE;
// if _pos now exactly at the end of _buf memory,
// we should reserve 1 byte for _dynamic_mode flag byte to avoid *pos = 254
// cause _dynamic_mode flag byte be overwritten
reserve(1);
*_pos++ = NEXT_EIGHT_BYTE; // *_pos = 254 ; _pos++
// write length when dynamic mode close
_len_pos = (_pos - _buf);
_pos = _pos + 8;