This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 5c68b772ccd branch-3.0: [Fix](multi-catalog) Fix column mutate() crash
replace it by assume_mutable(). #46151 (#46197)
5c68b772ccd is described below
commit 5c68b772ccda5a62b925afc9a84f624fe4bb852f
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Jan 1 08:17:38 2025 +0800
branch-3.0: [Fix](multi-catalog) Fix column mutate() crash replace it by
assume_mutable(). #46151 (#46197)
Cherry-picked from #46151
Co-authored-by: Qi Chen <[email protected]>
---
be/src/vec/exec/format/orc/vorc_reader.cpp | 7 ++++---
.../vec/exec/format/parquet/vparquet_column_reader.cpp | 16 ++++++++--------
be/src/vec/exec/format/parquet/vparquet_group_reader.cpp | 7 ++++---
be/src/vec/exec/scan/new_es_scanner.cpp | 2 +-
be/src/vec/exec/scan/vfile_scanner.cpp | 9 ++++-----
be/src/vec/exec/scan/vmeta_scanner.cpp | 2 +-
6 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/be/src/vec/exec/format/orc/vorc_reader.cpp
b/be/src/vec/exec/format/orc/vorc_reader.cpp
index 4d418306689..26e41afe3c9 100644
--- a/be/src/vec/exec/format/orc/vorc_reader.cpp
+++ b/be/src/vec/exec/format/orc/vorc_reader.cpp
@@ -1211,8 +1211,8 @@ Status OrcReader::_fill_missing_columns(
for (auto& kv : missing_columns) {
if (kv.second == nullptr) {
// no default column, fill with null
- auto nullable_column =
reinterpret_cast<vectorized::ColumnNullable*>(
-
(*std::move(block->get_by_name(kv.first).column)).mutate().get());
+ auto mutable_column =
block->get_by_name(kv.first).column->assume_mutable();
+ auto* nullable_column =
static_cast<vectorized::ColumnNullable*>(mutable_column.get());
nullable_column->insert_many_defaults(rows);
} else {
// fill with default value
@@ -1226,8 +1226,9 @@ Status OrcReader::_fill_missing_columns(
// call resize because the first column of _src_block_ptr may
not be filled by reader,
// so _src_block_ptr->rows() may return wrong result, cause
the column created by `ctx->execute()`
// has only one row.
-
std::move(*block->get_by_position(result_column_id).column).mutate()->resize(rows);
auto result_column_ptr =
block->get_by_position(result_column_id).column;
+ auto mutable_column = result_column_ptr->assume_mutable();
+ mutable_column->resize(rows);
// result_column_ptr maybe a ColumnConst, convert it to a
normal column
result_column_ptr =
result_column_ptr->convert_to_full_column_if_const();
auto origin_column_type = block->get_by_name(kv.first).type;
diff --git a/be/src/vec/exec/format/parquet/vparquet_column_reader.cpp
b/be/src/vec/exec/format/parquet/vparquet_column_reader.cpp
index d11b3153b49..207b917666b 100644
--- a/be/src/vec/exec/format/parquet/vparquet_column_reader.cpp
+++ b/be/src/vec/exec/format/parquet/vparquet_column_reader.cpp
@@ -679,8 +679,8 @@ Status ArrayColumnReader::read_column_data(ColumnPtr&
doris_column, DataTypePtr&
MutableColumnPtr data_column;
NullMap* null_map_ptr = nullptr;
if (doris_column->is_nullable()) {
- auto* nullable_column = reinterpret_cast<vectorized::ColumnNullable*>(
- (*std::move(doris_column)).mutate().get());
+ auto mutable_column = doris_column->assume_mutable();
+ auto* nullable_column =
static_cast<vectorized::ColumnNullable*>(mutable_column.get());
null_map_ptr = &nullable_column->get_null_map_data();
data_column = nullable_column->get_nested_column_ptr();
} else {
@@ -730,8 +730,8 @@ Status MapColumnReader::read_column_data(ColumnPtr&
doris_column, DataTypePtr& t
MutableColumnPtr data_column;
NullMap* null_map_ptr = nullptr;
if (doris_column->is_nullable()) {
- auto* nullable_column = reinterpret_cast<vectorized::ColumnNullable*>(
- (*std::move(doris_column)).mutate().get());
+ auto mutable_column = doris_column->assume_mutable();
+ auto* nullable_column =
static_cast<vectorized::ColumnNullable*>(mutable_column.get());
null_map_ptr = &nullable_column->get_null_map_data();
data_column = nullable_column->get_nested_column_ptr();
} else {
@@ -799,8 +799,8 @@ Status StructColumnReader::read_column_data(ColumnPtr&
doris_column, DataTypePtr
MutableColumnPtr data_column;
NullMap* null_map_ptr = nullptr;
if (doris_column->is_nullable()) {
- auto* nullable_column = reinterpret_cast<vectorized::ColumnNullable*>(
- (*std::move(doris_column)).mutate().get());
+ auto mutable_column = doris_column->assume_mutable();
+ auto* nullable_column =
static_cast<vectorized::ColumnNullable*>(mutable_column.get());
null_map_ptr = &nullable_column->get_null_map_data();
data_column = nullable_column->get_nested_column_ptr();
} else {
@@ -880,8 +880,8 @@ Status StructColumnReader::read_column_data(ColumnPtr&
doris_column, DataTypePtr
auto& doris_field = doris_struct.get_column_ptr(idx);
auto& doris_type =
const_cast<DataTypePtr&>(doris_struct_type->get_element(idx));
DCHECK(doris_type->is_nullable());
- auto* nullable_column = reinterpret_cast<vectorized::ColumnNullable*>(
- (*std::move(doris_field)).mutate().get());
+ auto mutable_column = doris_field->assume_mutable();
+ auto* nullable_column =
static_cast<vectorized::ColumnNullable*>(mutable_column.get());
nullable_column->insert_null_elements(missing_column_sz);
}
diff --git a/be/src/vec/exec/format/parquet/vparquet_group_reader.cpp
b/be/src/vec/exec/format/parquet/vparquet_group_reader.cpp
index 770ed1f02ac..a18626066b1 100644
--- a/be/src/vec/exec/format/parquet/vparquet_group_reader.cpp
+++ b/be/src/vec/exec/format/parquet/vparquet_group_reader.cpp
@@ -684,8 +684,8 @@ Status RowGroupReader::_fill_missing_columns(
for (auto& kv : missing_columns) {
if (kv.second == nullptr) {
// no default column, fill with null
- auto nullable_column =
reinterpret_cast<vectorized::ColumnNullable*>(
-
(*std::move(block->get_by_name(kv.first).column)).mutate().get());
+ auto mutable_column =
block->get_by_name(kv.first).column->assume_mutable();
+ auto* nullable_column =
static_cast<vectorized::ColumnNullable*>(mutable_column.get());
nullable_column->insert_many_defaults(rows);
} else {
// fill with default value
@@ -699,8 +699,9 @@ Status RowGroupReader::_fill_missing_columns(
// call resize because the first column of _src_block_ptr may
not be filled by reader,
// so _src_block_ptr->rows() may return wrong result, cause
the column created by `ctx->execute()`
// has only one row.
-
std::move(*block->get_by_position(result_column_id).column).mutate()->resize(rows);
auto result_column_ptr =
block->get_by_position(result_column_id).column;
+ auto mutable_column = result_column_ptr->assume_mutable();
+ mutable_column->resize(rows);
// result_column_ptr maybe a ColumnConst, convert it to a
normal column
result_column_ptr =
result_column_ptr->convert_to_full_column_if_const();
auto origin_column_type = block->get_by_name(kv.first).type;
diff --git a/be/src/vec/exec/scan/new_es_scanner.cpp
b/be/src/vec/exec/scan/new_es_scanner.cpp
index fae83854be0..b19b009b314 100644
--- a/be/src/vec/exec/scan/new_es_scanner.cpp
+++ b/be/src/vec/exec/scan/new_es_scanner.cpp
@@ -132,7 +132,7 @@ Status NewEsScanner::_get_block_impl(RuntimeState* state,
Block* block, bool* eo
columns.resize(column_size);
for (auto i = 0; i < column_size; i++) {
if (mem_reuse) {
- columns[i] =
std::move(*block->get_by_position(i).column).mutate();
+ columns[i] =
block->get_by_position(i).column->assume_mutable();
} else {
columns[i] =
_tuple_desc->slots()[i]->get_empty_mutable_column();
}
diff --git a/be/src/vec/exec/scan/vfile_scanner.cpp
b/be/src/vec/exec/scan/vfile_scanner.cpp
index 5b8e0c52fb2..48502209622 100644
--- a/be/src/vec/exec/scan/vfile_scanner.cpp
+++ b/be/src/vec/exec/scan/vfile_scanner.cpp
@@ -475,8 +475,8 @@ Status VFileScanner::_fill_missing_columns(size_t rows) {
for (auto& kv : _missing_col_descs) {
if (kv.second == nullptr) {
// no default column, fill with null
- auto nullable_column =
reinterpret_cast<vectorized::ColumnNullable*>(
-
(*std::move(_src_block_ptr->get_by_name(kv.first).column)).mutate().get());
+ auto mutable_column =
_src_block_ptr->get_by_name(kv.first).column->assume_mutable();
+ auto* nullable_column =
static_cast<vectorized::ColumnNullable*>(mutable_column.get());
nullable_column->insert_many_defaults(rows);
} else {
// fill with default value
@@ -490,10 +490,9 @@ Status VFileScanner::_fill_missing_columns(size_t rows) {
// call resize because the first column of _src_block_ptr may
not be filled by reader,
// so _src_block_ptr->rows() may return wrong result, cause
the column created by `ctx->execute()`
// has only one row.
-
std::move(*_src_block_ptr->get_by_position(result_column_id).column)
- .mutate()
- ->resize(rows);
auto result_column_ptr =
_src_block_ptr->get_by_position(result_column_id).column;
+ auto mutable_column = result_column_ptr->assume_mutable();
+ mutable_column->resize(rows);
// result_column_ptr maybe a ColumnConst, convert it to a
normal column
result_column_ptr =
result_column_ptr->convert_to_full_column_if_const();
auto origin_column_type =
_src_block_ptr->get_by_name(kv.first).type;
diff --git a/be/src/vec/exec/scan/vmeta_scanner.cpp
b/be/src/vec/exec/scan/vmeta_scanner.cpp
index 289930b16bc..7fbc3ed2d37 100644
--- a/be/src/vec/exec/scan/vmeta_scanner.cpp
+++ b/be/src/vec/exec/scan/vmeta_scanner.cpp
@@ -96,7 +96,7 @@ Status VMetaScanner::_get_block_impl(RuntimeState* state,
Block* block, bool* eo
columns.resize(column_size);
for (auto i = 0; i < column_size; i++) {
if (mem_reuse) {
- columns[i] =
std::move(*block->get_by_position(i).column).mutate();
+ columns[i] =
block->get_by_position(i).column->assume_mutable();
} else {
columns[i] =
_tuple_desc->slots()[i]->get_empty_mutable_column();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]