changed sibstring behaviour for offset < -string_lenght [#CLICKHOUSE-2090]

This commit is contained in:
Nikolai Kochetov 2017-09-01 17:32:12 +03:00
parent f1c01118b5
commit 5b4759acd9

View File

@ -296,7 +296,7 @@ struct StringSource
{
size_t elem_size = offsets[row_num] - prev_offset - 1;
if (offset > elem_size)
return {&elements[prev_offset], elem_size};
return {&elements[prev_offset], length + elem_size > offset ? std::min(elem_size, length + elem_size - offset) : 0};
return {&elements[prev_offset + elem_size - offset], std::min(length, offset)};
}
};
@ -375,7 +375,7 @@ struct FixedStringSource
Slice getSliceFromRight(size_t offset, size_t length) const
{
if (offset > string_size)
return {pos, string_size};
return {pos, length + string_size > offset ? std::min(string_size, length + string_size - offset) : 0};
return {pos + string_size - offset, std::min(length, offset)};
}
};