This is an automated email from the ASF dual-hosted git repository.

caiconghui pushed a commit to branch block
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 909e0495e8bfba507da9506ab52de0ed89886143
Author: caiconghui1 <caicongh...@jd.com>
AuthorDate: Sun Jan 14 23:39:17 2024 +0800

    [fix](block) make columns in block be nullptr when invoke mutate columns to 
avoid potential errors
---
 be/src/vec/core/block.cpp                     | 2 +-
 be/test/olap/delta_writer_test.cpp            | 2 ++
 be/test/olap/memtable_memory_limiter_test.cpp | 1 +
 be/test/olap/ordered_data_compaction_test.cpp | 2 ++
 be/test/olap/rowid_conversion_test.cpp        | 1 +
 be/test/olap/tablet_cooldown_test.cpp         | 1 +
 be/test/vec/olap/vertical_compaction_test.cpp | 1 +
 7 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/be/src/vec/core/block.cpp b/be/src/vec/core/block.cpp
index e3ce4885cb0..978594b7867 100644
--- a/be/src/vec/core/block.cpp
+++ b/be/src/vec/core/block.cpp
@@ -575,7 +575,7 @@ MutableColumns Block::mutate_columns() {
     size_t num_columns = data.size();
     MutableColumns columns(num_columns);
     for (size_t i = 0; i < num_columns; ++i) {
-        columns[i] = data[i].column ? (*std::move(data[i].column)).mutate()
+        columns[i] = data[i].column ? 
IColumn::mutate(std::move(data[i].column))
                                     : data[i].type->create_column();
     }
     return columns;
diff --git a/be/test/olap/delta_writer_test.cpp 
b/be/test/olap/delta_writer_test.cpp
index c48ebf98a48..4b24dbd5466 100644
--- a/be/test/olap/delta_writer_test.cpp
+++ b/be/test/olap/delta_writer_test.cpp
@@ -463,6 +463,7 @@ static void generate_data(vectorized::Block* block, int8_t 
k1, int16_t k2, int32
 
     int32_t c5 = seq;
     columns[4]->insert_data((const char*)&c5, sizeof(c2));
+    block.set_columns(std::move(columns));
 }
 
 class TestDeltaWriter : public ::testing::Test {
@@ -636,6 +637,7 @@ TEST_F(TestDeltaWriter, vec_write) {
         date_v2_int = date_v2.to_date_int_val();
         columns[21]->insert_data((const char*)&date_v2_int, 
sizeof(date_v2_int));
 
+        block.set_columns(std::move(columns));
         res = delta_writer->write(&block, {0});
         ASSERT_TRUE(res.ok());
     }
diff --git a/be/test/olap/memtable_memory_limiter_test.cpp 
b/be/test/olap/memtable_memory_limiter_test.cpp
index 34c7361e33e..f6e0c64b0be 100644
--- a/be/test/olap/memtable_memory_limiter_test.cpp
+++ b/be/test/olap/memtable_memory_limiter_test.cpp
@@ -166,6 +166,7 @@ TEST_F(MemTableMemoryLimiterTest, 
handle_memtable_flush_test) {
         int32_t k3 = -2147483647;
         columns[2]->insert_data((const char*)&k3, sizeof(k3));
 
+        block.set_columns(std::move(columns));
         res = delta_writer->write(&block, {0});
         ASSERT_TRUE(res.ok());
     }
diff --git a/be/test/olap/ordered_data_compaction_test.cpp 
b/be/test/olap/ordered_data_compaction_test.cpp
index dcdc6ed36ad..3c1cbcd4524 100644
--- a/be/test/olap/ordered_data_compaction_test.cpp
+++ b/be/test/olap/ordered_data_compaction_test.cpp
@@ -257,6 +257,8 @@ protected:
                 }
                 num_rows++;
             }
+
+            block.set_columns(std::move(columns));
             s = rowset_writer->add_block(&block);
             EXPECT_TRUE(s.ok());
             s = rowset_writer->flush();
diff --git a/be/test/olap/rowid_conversion_test.cpp 
b/be/test/olap/rowid_conversion_test.cpp
index d28e9f7dfe9..7a33a7921d9 100644
--- a/be/test/olap/rowid_conversion_test.cpp
+++ b/be/test/olap/rowid_conversion_test.cpp
@@ -209,6 +209,7 @@ protected:
                 }
                 num_rows++;
             }
+            block.set_columns(std::move(columns));
             s = rowset_writer->add_block(&block);
             EXPECT_TRUE(s.ok());
             s = rowset_writer->flush();
diff --git a/be/test/olap/tablet_cooldown_test.cpp 
b/be/test/olap/tablet_cooldown_test.cpp
index d83ea3eb016..d8a3222286d 100644
--- a/be/test/olap/tablet_cooldown_test.cpp
+++ b/be/test/olap/tablet_cooldown_test.cpp
@@ -369,6 +369,7 @@ void createTablet(TabletSharedPtr* tablet, int64_t 
replica_id, int32_t schema_ha
         int64_t c4_int = c4.to_int64();
         columns[3]->insert_data((const char*)&c4_int, sizeof(c4));
 
+        block.set_columns(std::move(columns));
         st = delta_writer->write(&block, {0});
         ASSERT_EQ(Status::OK(), st);
     }
diff --git a/be/test/vec/olap/vertical_compaction_test.cpp 
b/be/test/vec/olap/vertical_compaction_test.cpp
index fc458ab0dda..a46e8edd18e 100644
--- a/be/test/vec/olap/vertical_compaction_test.cpp
+++ b/be/test/vec/olap/vertical_compaction_test.cpp
@@ -258,6 +258,7 @@ protected:
                 }
                 num_rows++;
             }
+            block.set_columns(std::move(columns));
             s = rowset_writer->add_block(&block);
             EXPECT_TRUE(s.ok());
             s = rowset_writer->flush();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to