Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](ip) fix ip nullable param without check #44700

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 40 additions & 9 deletions be/src/vec/functions/function_ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,19 @@ class FunctionIPv6CIDRToRange : public IFunction {
auto& vec_res_upper_range = col_res_upper_range->get_data();

static constexpr UInt8 max_cidr_mask = IPV6_BINARY_LENGTH * 8;
unsigned char ipv6_address_data[IPV6_BINARY_LENGTH];

if (is_addr_const) {
StringRef str_ref = from_column.get_data_at(0);
const char* value = str_ref.data;
size_t value_size = str_ref.size;
if (value_size > IPV6_BINARY_LENGTH || value == nullptr || value_size == 0 ||
!IPv6Value::is_valid_string(value, value_size)) {
throw Exception(ErrorCode::INVALID_ARGUMENT, "Illegal ipv6 address '{}'",
std::string(value, value_size));
}
memcpy(ipv6_address_data, value, value_size);
memset(ipv6_address_data + value_size, 0, IPV6_BINARY_LENGTH - value_size);
for (size_t i = 0; i < input_rows_count; ++i) {
auto cidr = cidr_column.get_int(i);
if (cidr < 0 || cidr > max_cidr_mask) {
Expand All @@ -934,9 +945,9 @@ class FunctionIPv6CIDRToRange : public IFunction {
if constexpr (std::is_same_v<FromColumn, ColumnString>) {
// 16 bytes ipv6 string is stored in big-endian byte order
// so transfer to little-endian firstly
auto* src_data = const_cast<char*>(from_column.get_data_at(0).data);
std::reverse(src_data, src_data + IPV6_BINARY_LENGTH);
apply_cidr_mask(src_data, reinterpret_cast<char*>(&vec_res_lower_range[i]),
std::reverse(ipv6_address_data, ipv6_address_data + IPV6_BINARY_LENGTH);
apply_cidr_mask(reinterpret_cast<const char*>(&ipv6_address_data),
reinterpret_cast<char*>(&vec_res_lower_range[i]),
reinterpret_cast<char*>(&vec_res_upper_range[i]),
cast_set<UInt8>(cidr));
} else {
Expand All @@ -956,9 +967,19 @@ class FunctionIPv6CIDRToRange : public IFunction {
if constexpr (std::is_same_v<FromColumn, ColumnString>) {
// 16 bytes ipv6 string is stored in big-endian byte order
// so transfer to little-endian firstly
auto* src_data = const_cast<char*>(from_column.get_data_at(i).data);
std::reverse(src_data, src_data + IPV6_BINARY_LENGTH);
apply_cidr_mask(src_data, reinterpret_cast<char*>(&vec_res_lower_range[i]),
StringRef str_ref = from_column.get_data_at(i);
const char* value = str_ref.data;
size_t value_size = str_ref.size;
if (value_size > IPV6_BINARY_LENGTH || value == nullptr || value_size == 0 ||
!IPv6Value::is_valid_string(value, value_size)) {
throw Exception(ErrorCode::INVALID_ARGUMENT, "Illegal ipv6 address '{}'",
std::string(value, value_size));
}
memcpy(ipv6_address_data, value, value_size);
memset(ipv6_address_data + value_size, 0, IPV6_BINARY_LENGTH - value_size);
std::reverse(ipv6_address_data, ipv6_address_data + IPV6_BINARY_LENGTH);
apply_cidr_mask(reinterpret_cast<const char*>(&ipv6_address_data),
reinterpret_cast<char*>(&vec_res_lower_range[i]),
reinterpret_cast<char*>(&vec_res_upper_range[i]),
cast_set<UInt8>(cidr));
} else {
Expand All @@ -978,9 +999,19 @@ class FunctionIPv6CIDRToRange : public IFunction {
if constexpr (std::is_same_v<FromColumn, ColumnString>) {
// 16 bytes ipv6 string is stored in big-endian byte order
// so transfer to little-endian firstly
auto* src_data = const_cast<char*>(from_column.get_data_at(i).data);
std::reverse(src_data, src_data + IPV6_BINARY_LENGTH);
apply_cidr_mask(src_data, reinterpret_cast<char*>(&vec_res_lower_range[i]),
StringRef str_ref = from_column.get_data_at(i);
const char* value = str_ref.data;
size_t value_size = str_ref.size;
if (value_size > IPV6_BINARY_LENGTH || value == nullptr || value_size == 0 ||
!IPv6Value::is_valid_string(value, value_size)) {
throw Exception(ErrorCode::INVALID_ARGUMENT, "Illegal ipv6 address '{}'",
std::string(value, value_size));
}
memcpy(ipv6_address_data, value, value_size);
memset(ipv6_address_data + value_size, 0, IPV6_BINARY_LENGTH - value_size);
std::reverse(ipv6_address_data, ipv6_address_data + IPV6_BINARY_LENGTH);
apply_cidr_mask(reinterpret_cast<const char*>(&ipv6_address_data),
reinterpret_cast<char*>(&vec_res_lower_range[i]),
reinterpret_cast<char*>(&vec_res_upper_range[i]),
cast_set<UInt8>(cidr));
} else {
Expand Down
204 changes: 204 additions & 0 deletions regression-test/data/nereids_function_p0/scalar_function/IP.out
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,108 @@
99 {"min":"224.0.0.0", "max":"224.0.255.255"}
100 {"min":"224.0.0.0", "max":"224.0.255.255"}

-- !sql_cidr_ipv6_nullable_ --
1 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
2 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
3 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
4 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
5 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
6 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
7 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
8 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
9 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
10 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
11 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
12 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
13 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
14 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
15 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
16 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
17 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
18 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
19 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
20 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
21 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
22 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
23 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
24 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
25 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
26 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
27 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
28 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
29 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
30 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
31 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
32 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
33 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
34 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
35 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
36 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
37 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
38 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
39 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
40 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
41 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
42 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
43 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
44 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
45 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
46 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
47 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
48 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
49 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
50 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
51 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
52 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
53 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
54 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
55 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
56 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
57 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
58 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
59 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
60 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
61 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
62 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
63 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
64 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
65 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
66 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
67 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
68 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
69 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
70 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
71 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
72 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
73 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
74 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
75 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
76 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
77 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
78 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
79 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
80 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
81 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
82 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
83 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
84 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
85 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
86 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
87 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
88 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
89 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
90 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
91 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
92 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
93 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
94 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
95 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
96 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
97 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
98 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
99 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
100 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}

-- !sql_num2string_ipv6 --
1 ::1
2 fc00::
Expand Down Expand Up @@ -6121,6 +6223,108 @@
99 {"min":"224.0.0.0", "max":"224.0.255.255"}
100 {"min":"224.0.0.0", "max":"224.0.255.255"}

-- !sql_not_null_cidr_ipv6_nullable_ --
1 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
2 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
3 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
4 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
5 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
6 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
7 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
8 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
9 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
10 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
11 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
12 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
13 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
14 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
15 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
16 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
17 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
18 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
19 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
20 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
21 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
22 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
23 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
24 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
25 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
26 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
27 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
28 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
29 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
30 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
31 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
32 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
33 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
34 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
35 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
36 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
37 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
38 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
39 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
40 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
41 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
42 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
43 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
44 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
45 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
46 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
47 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
48 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
49 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
50 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
51 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
52 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
53 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
54 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
55 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
56 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
57 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
58 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
59 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
60 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
61 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
62 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
63 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
64 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
65 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
66 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
67 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
68 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
69 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
70 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
71 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
72 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
73 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
74 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
75 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
76 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
77 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
78 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
79 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
80 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
81 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
82 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
83 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
84 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
85 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
86 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
87 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
88 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
89 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
90 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
91 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
92 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
93 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
94 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
95 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
96 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
97 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
98 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
99 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}
100 {"min":"::", "max":"::ffff:ffff:ffff:ffff:ffff:ffff"}

-- !sql_not_null_ipv6_string_to_num --
1 00000000000000000000000000000001
2 FC000000000000000000000000000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ suite("nereids_scalar_fn_IP") {
qt_sql_cidr_ipv6_all """ select id, ipv6_cidr_to_range(ip6, 16) from fn_test_ip_nullable order by id; """
qt_sql_cidr_ipv4_all """ select id, ipv4_cidr_to_range(ip4, 16) from fn_test_ip_nullable order by id; """


// test nullable param
qt_sql_cidr_ipv6_nullable_ "select id, ipv6_cidr_to_range(to_ipv6('::'), 32) from fn_test_ip_nullable order by id;"
test {
sql "select id, ipv6_cidr_to_range(nullable(''), 32) from fn_test_ip_nullable order by id"
exception "Illegal ipv6 address"
}
// test IPV4_STRING_TO_NUM/IPV6_STRING_TO_NUM (we have null value in ip4 and ip6 column in fn_test_ip_nullable table)
test {
sql 'select id, ipv6_string_to_num(ip6) from fn_test_ip_nullable order by id'
Expand Down Expand Up @@ -153,7 +158,12 @@ suite("nereids_scalar_fn_IP") {
qt_sql_not_null_cidr_ipv6_all """ select id, ipv6_cidr_to_range(ip6, 16) from fn_test_ip_not_nullable order by id; """
qt_sql_not_null_cidr_ipv4_all """ select id, ipv4_cidr_to_range(ip4, 16) from fn_test_ip_not_nullable order by id; """


// test nullable param
qt_sql_not_null_cidr_ipv6_nullable_ "select id, ipv6_cidr_to_range(to_ipv6('::'), 32) from fn_test_ip_nullable order by id;"
test {
sql "select id, ipv6_cidr_to_range(nullable(''), 32) from fn_test_ip_not_nullable order by id"
exception "Illegal ipv6 address"
}
// test IPV4_STRING_TO_NUM/IPV6_STRING_TO_NUM
qt_sql_not_null_ipv6_string_to_num 'select id, hex(ipv6_string_to_num(ip6)) from fn_test_ip_not_nullable order by id'

Expand Down Expand Up @@ -269,4 +279,4 @@ suite("nereids_scalar_fn_IP") {
qt_sql_not_null_to_ipv4_or_null "select id, to_ipv4_or_null(ip6) from fn_test_ip_not_nullable order by id"
qt_sql_not_null_to_ipv4_or_null_str "select id, to_ipv4_or_null(ip6_str) from fn_test_ip_not_nullable order by id"

}
}
Loading