Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion be/src/vec/olap/vgeneric_iterators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ Status VMergeIteratorContext::copy_rows(Block* block, bool advanced) {
size_t start = _index_in_block - _cur_batch_num + 1 - advanced;

RETURN_IF_CATCH_EXCEPTION({
for (size_t i = 0; i < _num_columns; ++i) {
// Use block->columns() instead of `_iter->schema().num_key_columns()` to iterate over all columns actually present in the block.
// This prevents array out-of-bounds access when the read schema is dynamically changed.
// (e.g., delete predicates cause columns to be added).
// We now use block->columns() directly in copy_rows() to get the actual column count at runtime.
for (size_t i = 0; i < block->columns(); ++i) {
auto& s_col = src.get_by_position(i);
auto& d_col = dst.get_by_position(i);

Expand Down
2 changes: 0 additions & 2 deletions be/src/vec/olap/vgeneric_iterators.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class VMergeIteratorContext {
_sequence_id_idx(sequence_id_idx),
_is_unique(is_unique),
_is_reverse(is_reverse),
_num_columns(cast_set<int>(_iter->schema().num_column_ids())),
_num_key_columns(cast_set<int>(_iter->schema().num_key_columns())),
_compare_columns(read_orderby_key_columns) {}

Expand Down Expand Up @@ -175,7 +174,6 @@ class VMergeIteratorContext {
size_t _index_in_block = -1;
// 4096 minus 16 + 16 bytes padding that in padding pod array
int _block_row_max = 4064;
int _num_columns;
int _num_key_columns;
std::vector<uint32_t>* _compare_columns;
std::vector<RowLocation> _block_row_locations;
Expand Down
Loading