Fix parsing of IPv6 addresses longer than 39 characters

This commit is contained in:
Maksim Kita 2022-03-23 16:11:46 +01:00
parent 33938ce469
commit df0d3c9304
3 changed files with 14 additions and 1 deletions

View File

@ -11,7 +11,7 @@
constexpr size_t IPV4_BINARY_LENGTH = 4;
constexpr size_t IPV6_BINARY_LENGTH = 16;
constexpr size_t IPV4_MAX_TEXT_LENGTH = 15; /// Does not count tail zero byte.
constexpr size_t IPV6_MAX_TEXT_LENGTH = 39;
constexpr size_t IPV6_MAX_TEXT_LENGTH = 45; /// Does not count tail zero byte.
namespace DB
{

View File

@ -0,0 +1,3 @@
0 ::ffff:1.12.12.12
1 ::ffff:123.123.123.123
2 ::ffff:192.168.100.228

View File

@ -0,0 +1,10 @@
DROP TABLE IF EXISTS test_table;
CREATE TABLE test_table (id UInt64, value IPv6) ENGINE=MergeTree ORDER BY id;
INSERT INTO test_table VALUES (0, '0000:0000:0000:0000:0000:ffff:1.12.12.12');
INSERT INTO test_table VALUES (1, '0000:0000:0000:0000:0000:ffff:123.123.123.123');
INSERT INTO test_table VALUES (2, '0000:0000:0000:0000:0000:ffff:192.168.100.228');
SELECT * FROM test_table ORDER BY id;
DROP TABLE test_table;