This commit is contained in:
Pavel Kruglov 2021-06-10 20:41:33 +03:00
parent a9cf67ecf2
commit 29440011ae
2 changed files with 6 additions and 4 deletions

View File

@ -183,10 +183,12 @@ void ColumnString::expand(const IColumn::Filter & mask, bool inverted)
if (from < 0)
throw Exception("Too many bytes in mask", ErrorCodes::LOGICAL_ERROR);
int len = offsets_data[from] - offsets_data[from - 1];
/// Copy only if it makes sense.
size_t len = offsets_data[from] - offsets_data[from - 1];
/// Copy only if it makes sense. It's important to copy backward, because
/// ranges can overlap, but destination is always is more to the right then source
if (last_offset - len != offsets_data[from - 1])
memcpy(&chars_data[last_offset - len], &chars_data[offsets_data[from - 1]], len);
std::copy_backward(&chars_data[offsets_data[from - 1]], &chars_data[offsets_data[from]], &chars_data[last_offset]);
last_offset -= len;
--from;
}

View File

@ -206,7 +206,7 @@ int checkShirtCircuitArguments(const ColumnsWithTypeAndName & arguments)
int last_short_circuit_argument_index = -1;
for (size_t i = 0; i != arguments.size(); ++i)
{
if (const auto * column_function = checkAndGetShortCircuitArgument(arguments[i].column))
if (checkAndGetShortCircuitArgument(arguments[i].column))
last_short_circuit_argument_index = i;
}