Merge pull request #254 from hatarist/tostringcuttozero_ref

Improved toStringCutToZero description & added an example
This commit is contained in:
alexey-milovidov 2016-12-14 18:01:58 +04:00 committed by GitHub
commit 7cf1457b55
2 changed files with 32 additions and 2 deletions

View File

@ -4581,7 +4581,22 @@ Converts a String type argument to a FixedString(N) type (a string with fixed le
===toStringCutToZero(s)===
Accepts a String or FixedString argument. Returns a String and removes the null bytes from the end of the string.
Accepts a String or FixedString argument. Returns a String that is cut to a first null byte occurrence.
Example:
%%
:) SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut
┌─s─────────────┬─s_cut─┐
│ foo\0\0\0\0\0 │ foo │
└───────────────┴───────┘
:) SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut
┌─s──────────┬─s_cut─┐
│ foo\0bar\0 │ foo │
└────────────┴───────┘
%%
===reinterpretAsUInt8, reinterpretAsUInt16, reinterpretAsUInt32, reinterpretAsUInt64===
===reinterpretAsInt8, reinterpretAsInt16, reinterpretAsInt32, reinterpretAsInt64===

View File

@ -4645,7 +4645,22 @@ SELECT
===toStringCutToZero(s)===
Принимает аргумент типа String или FixedString. Возвращает String, удаляя нулевые байты с конца строки.
Принимает аргумент типа String или FixedString. Возвращает String, вырезая содержимое строки до первого найденного нулевого байта.
Пример:
%%
:) SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut
┌─s─────────────┬─s_cut─┐
│ foo\0\0\0\0\0 │ foo │
└───────────────┴───────┘
:) SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut
┌─s──────────┬─s_cut─┐
│ foo\0bar\0 │ foo │
└────────────┴───────┘
%%
===reinterpretAsUInt8, reinterpretAsUInt16, reinterpretAsUInt32, reinterpretAsUInt64===
===reinterpretAsInt8, reinterpretAsInt16, reinterpretAsInt32, reinterpretAsInt64===