This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 22b9cc6eb2e [fix](mysql)fix mysql row buf (#38145)
22b9cc6eb2e is described below
commit 22b9cc6eb2e0ae59992eaed2369b023c4cb3c590
Author: amory <[email protected]>
AuthorDate: Fri Jul 19 22:18:42 2024 +0800
[fix](mysql)fix mysql row buf (#38145)
## Proposed changes
backport: https://github.com/apache/doris/pull/37936
Issue Number: close #xxx
<!--Describe your changes.-->
---
be/src/util/mysql_row_buffer.cpp | 5 ++-
.../test_large_string_and_nested_type.out | 4 ++
.../test_large_string_and_nested_type.groovy | 46 ++++++++++++++++++++++
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/be/src/util/mysql_row_buffer.cpp b/be/src/util/mysql_row_buffer.cpp
index 3e4aa332cea..4823920508a 100644
--- a/be/src/util/mysql_row_buffer.cpp
+++ b/be/src/util/mysql_row_buffer.cpp
@@ -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
@@ -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;
diff --git
a/regression-test/data/datatype_p0/nested_types/corner_cases/test_large_string_and_nested_type.out
b/regression-test/data/datatype_p0/nested_types/corner_cases/test_large_string_and_nested_type.out
new file mode 100644
index 00000000000..a9e54877534
--- /dev/null
+++
b/regression-test/data/datatype_p0/nested_types/corner_cases/test_large_string_and_nested_type.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql --
+1
bbyNAEofVG2QVSEnKaKtNIZRA9BgH409IxsionnxaH5z70Ttfz5mobCvUA5xM7O6jPMLHEoSkngDfficKjKJISfl822rQlrYithBeQLVw1upYyXCTxtS2Nl0B3vi3tGeN4j6kPuhJoCQLLSivaHQrTgCCpV8ItDuQIoiRlkolabnjDHKShh3YracboXMHAYebiUxuaq3G3glxz09zXccRCgXzyDUIV4sJMO0GsE8JDo2QnzZpIcUvngS8uJhyIes0eIuPTAVFWQzYlEPopQKViLSzckSi86yIUnNABwFSTp6CTL651nNe9XifaXqQphZdnrLs7ngSJVexlSVLc2ECV1e1ZCP98L18gtgsG8P0LbUaTiWQULfSiMBtt1h2N5AjOVLQaHrkquETQDmyAhYipPfHxp9In6GFlpilAJQFpOxRe54xkiYkBMQAO4hTq0reOjDH71hqH1fWrRe1CYbjhbh1PUQlWUsjgEM9FwVGz
[...]
+
diff --git
a/regression-test/suites/datatype_p0/nested_types/corner_cases/test_large_string_and_nested_type.groovy
b/regression-test/suites/datatype_p0/nested_types/corner_cases/test_large_string_and_nested_type.groovy
new file mode 100644
index 00000000000..28a68681f7c
--- /dev/null
+++
b/regression-test/suites/datatype_p0/nested_types/corner_cases/test_large_string_and_nested_type.groovy
@@ -0,0 +1,46 @@
+import org.apache.commons.lang3.StringUtils
+
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_large_string_and_nested_type", "p0") {
+ sql """ DROP TABLE IF EXISTS test_large_string_and_nested_type"""
+ sql """ CREATE TABLE `test_large_string_and_nested_type` (
+ `col1` INT NULL,
+ `col2` VARCHAR(49053) NOT NULL,
+ `col3` MAP<TEXT,TEXT> NULL
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`col1`)
+ COMMENT 'OLAP'
+ DISTRIBUTED BY HASH(`col1`) BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "min_load_replica_num" = "-1",
+ "is_being_synced" = "false",
+ "storage_medium" = "hdd",
+ "storage_format" = "V2",
+ "inverted_index_storage_format" = "V2",
+ "light_schema_change" = "true",
+ "disable_auto_compaction" = "false",
+ "enable_single_replica_compaction" = "false",
+ "group_commit_interval_ms" = "10000",
+ "group_commit_data_bytes" = "134217728"
+ );
+ """
+ sql """INSERT INTO test_large_string_and_nested_type VALUES (1,
'bbyNAEofVG2QVSEnKaKtNIZRA9BgH409IxsionnxaH5z70Ttfz5mobCvUA5xM7O6jPMLHEoSkngDfficKjKJISfl822rQlrYithBeQLVw1upYyXCTxtS2Nl0B3vi3tGeN4j6kPuhJoCQLLSivaHQrTgCCpV8ItDuQIoiRlkolabnjDHKShh3YracboXMHAYebiUxuaq3G3glxz09zXccRCgXzyDUIV4sJMO0GsE8JDo2QnzZpIcUvngS8uJhyIes0eIuPTAVFWQzYlEPopQKViLSzckSi86yIUnNABwFSTp6CTL651nNe9XifaXqQphZdnrLs7ngSJVexlSVLc2ECV1e1ZCP98L18gtgsG8P0LbUaTiWQULfSiMBtt1h2N5AjOVLQaHrkquETQDmyAhYipPfHxp9In6GFlpilAJ
[...]
+ qt_sql """ select * from test_large_string_and_nested_type """
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]