Fixed function toStringCutToZero with argument of type String [#CLICKHOUSE-2958].

This commit is contained in:
Alexey Milovidov 2017-04-17 20:49:11 +03:00
parent b51c6e7592
commit f76680d47e
3 changed files with 10 additions and 3 deletions

View File

@ -1759,16 +1759,19 @@ public:
char * begin = reinterpret_cast<char *>(&out_vec[0]); char * begin = reinterpret_cast<char *>(&out_vec[0]);
char * pos = begin; char * pos = begin;
const char * pos_in = reinterpret_cast<const char *>(&in_vec[0]);
ColumnString::Offset_t current_in_offset = 0;
for (size_t i = 0; i < size; ++i) for (size_t i = 0; i < size; ++i)
{ {
const char * pos_in = reinterpret_cast<const char *>(&in_vec[current_in_offset]);
size_t current_size = strlen(pos_in); size_t current_size = strlen(pos_in);
memcpySmallAllowReadWriteOverflow15(pos, pos_in, current_size); memcpySmallAllowReadWriteOverflow15(pos, pos_in, current_size);
pos += current_size; pos += current_size;
*pos = '\0'; *pos = '\0';
out_offsets[i] = ++pos - begin; ++pos;
pos_in += in_offsets[i]; out_offsets[i] = pos - begin;
current_in_offset = in_offsets[i];
} }
out_vec.resize(pos - begin); out_vec.resize(pos - begin);

View File

@ -0,0 +1,2 @@
1
1

View File

@ -0,0 +1,2 @@
SELECT DISTINCT toString(number) = toStringCutToZero(toString(number)) FROM (SELECT * FROM system.numbers LIMIT 1000);
SELECT DISTINCT toString(number) = toStringCutToZero(toFixedString(toString(number), 10)) FROM (SELECT * FROM system.numbers LIMIT 1000);