Skip to content

Commit

Permalink
[fix](mysql)fix mysql row buf (#38145)
Browse files Browse the repository at this point in the history
## Proposed changes
backport: #37936
Issue Number: close #xxx

<!--Describe your changes.-->
  • Loading branch information
amorynan authored Jul 19, 2024
1 parent 7b141ff commit 22b9cc6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
5 changes: 4 additions & 1 deletion be/src/util/mysql_row_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ namespace doris {
static uint8_t NEXT_TWO_BYTE = 252;
static uint8_t NEXT_THREE_BYTE = 253;
static uint8_t NEXT_EIGHT_BYTE = 254;
// the EXTRA_RESERVE_BYTE wanner to make sure _pos pointer is always in _buf memory
// used in reserve() for allocate current buffer
static size_t EXTRA_RESERVE_BYTE = 16;

// the first byte:
// <= 250: length
Expand Down Expand Up @@ -133,7 +136,7 @@ int MysqlRowBuffer<is_binary_format>::reserve(int64_t size) {
return 0;
}

int64_t alloc_size = std::max(need_size, _buf_size * 2);
int64_t alloc_size = std::max(need_size, _buf_size * 2) + EXTRA_RESERVE_BYTE;
char* new_buf = new char[alloc_size];

size_t offset = _pos - _buf;
Expand Down
Loading

0 comments on commit 22b9cc6

Please sign in to comment.