mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
fix read extra bytes when with separator
This commit is contained in:
parent
ee2ca536ff
commit
b820cfb3b6
@ -634,12 +634,22 @@ inline bool tryReadDateText(DayNum & date, ReadBuffer & buf)
|
||||
inline void readUUIDText(UUID & uuid, ReadBuffer & buf)
|
||||
{
|
||||
char s[36];
|
||||
size_t size = buf.read(s, 36);
|
||||
size_t size = buf.read(s, 32);
|
||||
|
||||
if (size >= 32)
|
||||
if (size == 32)
|
||||
{
|
||||
if (s[8] == '-')
|
||||
{
|
||||
size += buf.read(&s[32], 4);
|
||||
|
||||
if (size != 36)
|
||||
{
|
||||
s[size] = 0;
|
||||
throw Exception(std::string("Cannot parse uuid ") + s, ErrorCodes::CANNOT_PARSE_UUID);
|
||||
}
|
||||
|
||||
parseUUID<true>(reinterpret_cast<const UInt8 *>(s), std::reverse_iterator<UInt8 *>(reinterpret_cast<UInt8 *>(&uuid) + 16));
|
||||
}
|
||||
else
|
||||
parseUUID<false>(reinterpret_cast<const UInt8 *>(s), std::reverse_iterator<UInt8 *>(reinterpret_cast<UInt8 *>(&uuid) + 16));
|
||||
}
|
||||
|
@ -1,2 +1,4 @@
|
||||
417ddc5d-e556-4d27-95dd-a34d84e46a50
|
||||
417ddc5d-e556-4d27-95dd-a34d84e46a50
|
||||
1 417ddc5d-e556-4d27-95dd-a34d84e46a50 Example 1
|
||||
2 417ddc5d-e556-4d27-95dd-a34d84e46a51 Example 2
|
||||
|
@ -1,2 +1,11 @@
|
||||
SELECT toUUID('417ddc5de5564d2795dda34d84e46a50');
|
||||
SELECT toUUID('417ddc5d-e556-4d27-95dd-a34d84e46a50');
|
||||
|
||||
DROP TABLE IF EXISTS t_uuid;
|
||||
CREATE TABLE t_uuid (x UInt8, y UUID, z String) ENGINE = TinyLog;
|
||||
|
||||
INSERT INTO t_uuid VALUES (1, '417ddc5de5564d2795dda34d84e46a50', 'Example 1');
|
||||
INSERT INTO t_uuid VALUES (2, '417ddc5d-e556-4d27-95dd-a34d84e46a51', 'Example 2');
|
||||
|
||||
SELECT * FROM t_uuid ORDER BY x ASC;
|
||||
DROP TABLE IF EXISTS t_uuid;
|
||||
|
Loading…
Reference in New Issue
Block a user