[fix](concat) ColumnString::chars is resized with wrong size (#22610)

FunctionStringConcat::execute_impl resized with size that include string null terminator, which causes ColumnString::chars.size() does not match with ColumnString::offsets.back, this will cause problems for some string functions, e.g. like and regexp.
This commit is contained in:
TengJianPing
2023-08-04 19:13:35 +08:00
committed by GitHub
parent 872280135d
commit b122f9b80c
4 changed files with 78 additions and 2 deletions

View File

@ -35,6 +35,23 @@
namespace doris::vectorized {
void ColumnString::sanity_check() const {
auto count = offsets.size();
if (chars.size() != offsets[count - 1]) {
LOG(FATAL) << "row count: " << count << ", chars.size(): " << chars.size() << ", offset["
<< count - 1 << "]: " << offsets[count - 1];
}
if (offsets[-1] != 0) {
LOG(FATAL) << "wrong offsets[-1]: " << offsets[-1];
}
for (size_t i = 0; i < count; ++i) {
if (offsets[i] < offsets[i - 1]) {
LOG(FATAL) << "row count: " << count << ", offsets[" << i << "]: " << offsets[i]
<< ", offsets[" << i - 1 << "]: " << offsets[i - 1];
}
}
}
MutableColumnPtr ColumnString::clone_resized(size_t to_size) const {
auto res = ColumnString::create();
if (to_size == 0) {