You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ca...@apache.org on 2022/10/10 03:42:21 UTC
[doris] branch master updated: [Bug](array-type) Fix memory buffer overflow (#13074)
This is an automated email from the ASF dual-hosted git repository.
cambyzju pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 20b583c91e [Bug](array-type) Fix memory buffer overflow (#13074)
20b583c91e is described below
commit 20b583c91ed3e75e3893b0fb02e60ab4c91e7647
Author: xy720 <22...@users.noreply.github.com>
AuthorDate: Mon Oct 10 11:42:13 2022 +0800
[Bug](array-type) Fix memory buffer overflow (#13074)
---
be/src/olap/rowset/segment_v2/column_reader.cpp | 1 +
be/src/olap/rowset/segment_v2/column_reader.h | 2 +-
be/src/olap/rowset/segment_v2/column_writer.cpp | 4 ++--
.../sql_functions/array_functions/sql/q03.out | 20 ++++++++++++++++++++
.../sql_functions/array_functions/sql/q03.sql | 6 ++++++
5 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/be/src/olap/rowset/segment_v2/column_reader.cpp b/be/src/olap/rowset/segment_v2/column_reader.cpp
index 1d0345ebb8..6ee44e6e0a 100644
--- a/be/src/olap/rowset/segment_v2/column_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/column_reader.cpp
@@ -755,6 +755,7 @@ Status FileColumnIterator::next_batch_of_zone_map(size_t* n, vectorized::Mutable
Status FileColumnIterator::next_batch(size_t* n, vectorized::MutableColumnPtr& dst,
bool* has_null) {
size_t curr_size = dst->byte_size();
+ dst->reserve(*n);
size_t remaining = *n;
*has_null = false;
while (remaining > 0) {
diff --git a/be/src/olap/rowset/segment_v2/column_reader.h b/be/src/olap/rowset/segment_v2/column_reader.h
index d165dff067..ca6e08e229 100644
--- a/be/src/olap/rowset/segment_v2/column_reader.h
+++ b/be/src/olap/rowset/segment_v2/column_reader.h
@@ -375,7 +375,7 @@ public:
class ArrayFileColumnIterator final : public ColumnIterator {
public:
- explicit ArrayFileColumnIterator(ColumnReader* reader, FileColumnIterator* length_reader,
+ explicit ArrayFileColumnIterator(ColumnReader* reader, FileColumnIterator* offset_reader,
ColumnIterator* item_iterator, ColumnIterator* null_iterator);
~ArrayFileColumnIterator() override = default;
diff --git a/be/src/olap/rowset/segment_v2/column_writer.cpp b/be/src/olap/rowset/segment_v2/column_writer.cpp
index caf9dc0629..2f1696a435 100644
--- a/be/src/olap/rowset/segment_v2/column_writer.cpp
+++ b/be/src/olap/rowset/segment_v2/column_writer.cpp
@@ -513,13 +513,13 @@ Status ScalarColumnWriter::finish_current_page() {
////////////////////////////////////////////////////////////////////////////////
ArrayColumnWriter::ArrayColumnWriter(const ColumnWriterOptions& opts, std::unique_ptr<Field> field,
- ScalarColumnWriter* length_writer,
+ ScalarColumnWriter* offset_writer,
ScalarColumnWriter* null_writer,
std::unique_ptr<ColumnWriter> item_writer)
: ColumnWriter(std::move(field), opts.meta->is_nullable()),
_item_writer(std::move(item_writer)),
_opts(opts) {
- _offset_writer.reset(length_writer);
+ _offset_writer.reset(offset_writer);
if (is_nullable()) {
_null_writer.reset(null_writer);
}
diff --git a/regression-test/data/query_p0/sql_functions/array_functions/sql/q03.out b/regression-test/data/query_p0/sql_functions/array_functions/sql/q03.out
new file mode 100644
index 0000000000..fb16bef5ae
--- /dev/null
+++ b/regression-test/data/query_p0/sql_functions/array_functions/sql/q03.out
@@ -0,0 +1,20 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !q03 --
+0
+
+-- !q03_2 --
+0
+
+-- !q03_3 --
+0
+
+-- !q03_4 --
+0
+
+-- !q03_5 --
+3
+
+-- !q03_6 --
+[1001]
+[1001]
+[1002]
diff --git a/regression-test/suites/query_p0/sql_functions/array_functions/sql/q03.sql b/regression-test/suites/query_p0/sql_functions/array_functions/sql/q03.sql
new file mode 100644
index 0000000000..f87f346cfe
--- /dev/null
+++ b/regression-test/suites/query_p0/sql_functions/array_functions/sql/q03.sql
@@ -0,0 +1,6 @@
+ADMIN SET FRONTEND CONFIG ('enable_array_type' = 'true');
+set enable_vectorized_engine=true;
+DROP TABLE IF EXISTS array_insert_select_test;
+CREATE TABLE array_insert_select_test (id int, c_array array<int(11)>) ENGINE = Olap DUPLICATE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES('replication_num' = '1');
+insert into array_insert_select_test select k1, collect_list(k3) from test_query_db.test group by k1;
+select c_array from array_insert_select_test;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org