This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 384757bb259 [fix](ip-funcs) fix inet6_aton case #39415 (#39512)
384757bb259 is described below
commit 384757bb2599c34a603bf3c335c39a3ef0389dfe
Author: amory <[email protected]>
AuthorDate: Sat Aug 17 10:58:20 2024 +0800
[fix](ip-funcs) fix inet6_aton case #39415 (#39512)
---
be/src/vec/functions/function_ip.h | 6 +-
.../ip_functions/test_ip_functions.out | 308 +++++++++++++++++++++
.../ip_functions/test_ip_functions.groovy | 33 +++
3 files changed, 344 insertions(+), 3 deletions(-)
diff --git a/be/src/vec/functions/function_ip.h
b/be/src/vec/functions/function_ip.h
index 3b02d779246..9d74346c0ce 100644
--- a/be/src/vec/functions/function_ip.h
+++ b/be/src/vec/functions/function_ip.h
@@ -391,7 +391,6 @@ ColumnPtr convert_to_ipv6(const StringColumnType&
string_column,
const Chars& vec_src = string_column.get_chars();
size_t src_offset = 0;
- char src_ipv4_buf[sizeof("::ffff:") + IPV4_MAX_TEXT_LENGTH + 1] =
"::ffff:";
/// ColumnString contains not null terminated strings. But functions
parseIPv6, parseIPv4 expect null terminated string.
/// TODO fix this - now parseIPv6/parseIPv4 accept end iterator, so can be
parsed in-place
@@ -403,6 +402,7 @@ ColumnPtr convert_to_ipv6(const StringColumnType&
string_column,
}
for (size_t out_offset = 0, i = 0; i < column_size; out_offset +=
offset_inc, ++i) {
+ char src_ipv4_buf[sizeof("::ffff:") + IPV4_MAX_TEXT_LENGTH + 1] =
"::ffff:";
size_t src_next_offset = src_offset;
const char* src_value = nullptr;
@@ -446,7 +446,7 @@ ColumnPtr convert_to_ipv6(const StringColumnType&
string_column,
size_t string_length = src_next_offset - src_offset;
if (string_length != 0) {
if (try_parse_ipv4(src_value, dummy_result)) {
- strcat(src_ipv4_buf, src_value);
+ strncat(src_ipv4_buf, src_value, sizeof(src_ipv4_buf) -
strlen(src_ipv4_buf) - 1);
parse_result = parse_ipv6_whole(src_ipv4_buf, res_value);
} else {
parse_result = parse_ipv6_whole(src_value, res_value);
@@ -1296,4 +1296,4 @@ private:
}
};
-} // namespace doris::vectorized
\ No newline at end of file
+} // namespace doris::vectorized
diff --git
a/regression-test/data/query_p0/sql_functions/ip_functions/test_ip_functions.out
b/regression-test/data/query_p0/sql_functions/ip_functions/test_ip_functions.out
index 799d441a70a..7eaae19f874 100644
---
a/regression-test/data/query_p0/sql_functions/ip_functions/test_ip_functions.out
+++
b/regression-test/data/query_p0/sql_functions/ip_functions/test_ip_functions.out
@@ -1,3 +1,4 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
-- !sql --
\N
@@ -228,3 +229,310 @@ true
-- !sql --
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
+
+-- !sql --
+\N
+\N
+00000000000000000000FFFF05E335D4
+00000000000000000000FFFF1261A646
+00000000000000000000FFFF1261A646
+00000000000000000000FFFF1657D94D
+00000000000000000000FFFF1657D94D
+00000000000000000000FFFF1657D94D
+00000000000000000000FFFF1657D94D
+00000000000000000000FFFF170DCEF3
+00000000000000000000FFFF193DADAC
+00000000000000000000FFFF231C9A15
+00000000000000000000FFFF26CF8C4C
+00000000000000000000FFFF26CF8C4C
+00000000000000000000FFFF43BCEDC8
+00000000000000000000FFFF4A9FA80C
+00000000000000000000FFFF4A9FA80C
+00000000000000000000FFFF4A9FA80C
+00000000000000000000FFFF52DB2151
+00000000000000000000FFFF52DB2151
+00000000000000000000FFFF574065FB
+00000000000000000000FFFF574065FB
+00000000000000000000FFFF574065FB
+00000000000000000000FFFF5BB1F048
+00000000000000000000FFFF655EB658
+00000000000000000000FFFF655EB658
+00000000000000000000FFFF66B60F50
+00000000000000000000FFFF66B60F50
+00000000000000000000FFFF6AFCBD17
+00000000000000000000FFFF6F88A9AA
+00000000000000000000FFFF8FC00055
+00000000000000000000FFFF8FC00055
+00000000000000000000FFFF8FC00055
+00000000000000000000FFFF8FC00055
+00000000000000000000FFFF9306907C
+00000000000000000000FFFF9A9DDD96
+00000000000000000000FFFF9A9DDD96
+00000000000000000000FFFF9EEE315F
+00000000000000000000FFFFC4661A93
+00000000000000000000FFFFC4C1765E
+00000000000000000000FFFFC4C1765E
+00000000000000000000FFFFE853974E
+00000000000000000000FFFFE853974E
+00000000000000000000FFFFE853974E
+00000000000000000000FFFFE853974E
+00000000000000000000FFFFE853974E
+00000000000000000000FFFFFEA21B5E
+00000000000000000000FFFFFEA21B5E
+0092B192BC620FACBB893156D7B582CF
+073BA410A0D25C99C673E6DA8D3AEE5C
+09A7F88F84DC70417D2A823888CAF56C
+09A7F88F84DC70417D2A823888CAF56C
+1A2E70E805FE5C92FFE01CB830AF066C
+29A49E8C43F3C82D2E7C93365C4D08FE
+2CD1F7ECDE4CC82C77E01E4675A5AD20
+38561AFF7B096688A449922405633E67
+38561AFF7B096688A449922405633E67
+56D3B4AC98690667B045609B92CFEFB7
+56D3B4AC98690667B045609B92CFEFB7
+56D3B4AC98690667B045609B92CFEFB7
+5E750ED967AF0FA6C3F867CBCB3C9A1E
+5E750ED967AF0FA6C3F867CBCB3C9A1E
+648A1DB325AF53486CA13497AF4AA803
+648A1DB325AF53486CA13497AF4AA803
+648A1DB325AF53486CA13497AF4AA803
+77C70C0DDD9CD35616AC565A88D4CE2A
+77C70C0DDD9CD35616AC565A88D4CE2A
+7BD911222CC1E78221155246EF55F2D3
+7EFDC3EDE53B679B6FBA7EE16FBAFE3B
+8AE99A78CA90E5E9A2A0CA4ED9F93BEA
+8AE99A78CA90E5E9A2A0CA4ED9F93BEA
+946C7A3FDC207DCE664AB332E0AA325A
+946C7A3FDC207DCE664AB332E0AA325A
+946C7A3FDC207DCE664AB332E0AA325A
+946C7A3FDC207DCE664AB332E0AA325A
+946C7A3FDC207DCE664AB332E0AA325A
+946C7A3FDC207DCE664AB332E0AA325A
+A298F78FE4DFED9DC1C3F245FF48BD87
+A298F78FE4DFED9DC1C3F245FF48BD87
+A30DA1987ECDE0BB161B51893BE77CD0
+A30DA1987ECDE0BB161B51893BE77CD0
+A7FE653A0A25D2BD8CDA98B3A02124A9
+A7FE653A0A25D2BD8CDA98B3A02124A9
+ACDAA8039F635FD830BB76CE880B6531
+B1BBF2EB5D3FCFAA37BEA3F5E6E189C7
+B1BBF2EB5D3FCFAA37BEA3F5E6E189C7
+B1BBF2EB5D3FCFAA37BEA3F5E6E189C7
+B1BBF2EB5D3FCFAA37BEA3F5E6E189C7
+C0C2A55F88DBE6185DC2777934C10D4C
+DD29515F42C3FE220435D73C22C0701F
+E8B2FA6FBF0A2A9370E15D455AF02FBC
+E8B2FA6FBF0A2A9370E15D455AF02FBC
+E8B2FA6FBF0A2A9370E15D455AF02FBC
+F05B559C2DA5365A94F7D991F86A7731
+FCC2A56C2DFFFB0F07CF8FB7D5D40598
+FCC2A56C2DFFFB0F07CF8FB7D5D40598
+FCC2A56C2DFFFB0F07CF8FB7D5D40598
+FCD72C04ADE0A97425C2C1E74F2CF1BB
+FE216EFEE832A67462BBF616FC2CC2AF
+FE216EFEE832A67462BBF616FC2CC2AF
+
+-- !sql --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+1261A646
+1261A646
+1657D94D
+1657D94D
+1657D94D
+1657D94D
+170DCEF3
+193DADAC
+231C9A15
+26CF8C4C
+26CF8C4C
+43BCEDC8
+4A9FA80C
+4A9FA80C
+4A9FA80C
+52DB2151
+52DB2151
+574065FB
+574065FB
+574065FB
+5BB1F048
+5E335D4
+655EB658
+655EB658
+66B60F50
+66B60F50
+6AFCBD17
+6F88A9AA
+8FC00055
+8FC00055
+8FC00055
+8FC00055
+9306907C
+9A9DDD96
+9A9DDD96
+9EEE315F
+C4661A93
+C4C1765E
+C4C1765E
+E853974E
+E853974E
+E853974E
+E853974E
+E853974E
+FEA21B5E
+FEA21B5E
+
+-- !sql --
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+1261A646
+1261A646
+1657D94D
+1657D94D
+1657D94D
+1657D94D
+170DCEF3
+193DADAC
+231C9A15
+26CF8C4C
+26CF8C4C
+43BCEDC8
+4A9FA80C
+4A9FA80C
+4A9FA80C
+52DB2151
+52DB2151
+574065FB
+574065FB
+574065FB
+5BB1F048
+5E335D4
+655EB658
+655EB658
+66B60F50
+66B60F50
+6AFCBD17
+6F88A9AA
+8FC00055
+8FC00055
+8FC00055
+8FC00055
+9306907C
+9A9DDD96
+9A9DDD96
+9EEE315F
+C4661A93
+C4C1765E
+C4C1765E
+E853974E
+E853974E
+E853974E
+E853974E
+E853974E
+FEA21B5E
+FEA21B5E
+
diff --git
a/regression-test/suites/query_p0/sql_functions/ip_functions/test_ip_functions.groovy
b/regression-test/suites/query_p0/sql_functions/ip_functions/test_ip_functions.groovy
index 333e9e8a4b8..5373217503a 100644
---
a/regression-test/suites/query_p0/sql_functions/ip_functions/test_ip_functions.groovy
+++
b/regression-test/suites/query_p0/sql_functions/ip_functions/test_ip_functions.groovy
@@ -100,4 +100,37 @@ suite("test_ip_functions", "arrow_flight_sql") {
qt_sql "SELECT ipv6_num_to_string(ipv6_string_to_num('::ffff:c0a8:0001'));"
qt_sql "SELECT ipv6_num_to_string(ipv6_string_to_num('::'));"
qt_sql "SELECT
ipv6_num_to_string(ipv6_string_to_num('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'));"
+
+ // we should test the _null and _default
+ sql """ DROP TABLE IF EXISTS
table_100_undef_partitions2_keys3_properties4_distributed_by5 """
+ sql """
+ create table table_100_undef_partitions2_keys3_properties4_distributed_by5
(
+ pk int,
+ col_varchar_255__undef_signed varchar(255) null ,
+ col_varchar_255__undef_signed_index_inverted varchar(255) null ,
+ col_varchar_255__undef_signed_not_null varchar(255) not null ,
+ col_varchar_255__undef_signed_not_null_index_inverted varchar(255) not
null ,
+ col_ipv4_undef_signed ipv4 null ,
+ col_ipv4_undef_signed_not_null ipv4 not null ,
+ col_ipv6_undef_signed ipv6 null ,
+ col_ipv6_undef_signed_not_null ipv6 not null ,
+ col_ipv4_undef_signed2 ipv4 null ,
+ col_ipv4_undef_signed_not_null2 ipv4 not null ,
+ col_ipv6_undef_signed2 ipv6 null ,
+ col_ipv6_undef_signed_not_null2 ipv6 not null ,
+ INDEX col_varchar_255__undef_signed_index_inverted_idx
(`col_varchar_255__undef_signed_index_inverted`) USING INVERTED,
+ INDEX col_varchar_255__undef_signed_not_null_index_inverted_idx
(`col_varchar_255__undef_signed_not_null_index_inverted`) USING INVERTED
+ ) engine=olap
+ DUPLICATE KEY(pk)
+ distributed by hash(pk) buckets 10
+ properties("replication_num" = "1");
+ """
+
+ sql """ insert into
table_100_undef_partitions2_keys3_properties4_distributed_by5(pk,col_varchar_255__undef_signed,col_varchar_255__undef_signed_index_inverted,col_varchar_255__undef_signed_not_null,col_varchar_255__undef_signed_not_null_index_inverted,col_ipv4_undef_signed,col_ipv4_undef_signed_not_null,col_ipv6_undef_signed,col_ipv6_undef_signed_not_null,col_ipv4_undef_signed2,col_ipv4_undef_signed_not_null2,col_ipv6_undef_signed2,col_ipv6_undef_signed_not_null2)
values (0,'you','7 [...]
+"""
+
+ order_qt_sql """ select
hex(inet6_aton(col_varchar_255__undef_signed_index_inverted)) col_alias5 from
table_100_undef_partitions2_keys3_properties4_distributed_by5 order by pk"""
+ order_qt_sql """ select
hex(ipv4_string_to_num_or_null(col_varchar_255__undef_signed_index_inverted))
col_alias5 from table_100_undef_partitions2_keys3_properties4_distributed_by5
order by pk """
+ order_qt_sql """ select
hex(ipv4_string_to_num_or_default(col_varchar_255__undef_signed_index_inverted))
col_alias5 from table_100_undef_partitions2_keys3_properties4_distributed_by5
order by pk """
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]