This is an automated email from the ASF dual-hosted git repository.
lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 460eb0fa98d [improve](function) add limit check for lpad/rpad function
input big value of length (#34810)
460eb0fa98d is described below
commit 460eb0fa98dff7a3ed09f68bd25a8f66058d28f7
Author: zhangstar333 <[email protected]>
AuthorDate: Mon May 20 11:38:02 2024 +0800
[improve](function) add limit check for lpad/rpad function input big value
of length (#34810)
---
be/src/vec/functions/function_string.h | 8 ++++++++
regression-test/data/query_p1/test_big_pad.out | 4 ++++
regression-test/suites/query_p1/test_big_pad.groovy | 7 +++++++
3 files changed, 19 insertions(+)
diff --git a/be/src/vec/functions/function_string.h
b/be/src/vec/functions/function_string.h
index 88bdd7d760b..8aa10e41661 100644
--- a/be/src/vec/functions/function_string.h
+++ b/be/src/vec/functions/function_string.h
@@ -1715,6 +1715,14 @@ public:
res_chars, res_offsets);
continue;
}
+ if (col_len_data[i] > context->state()->repeat_max_num()) {
+ return Status::InvalidArgument(
+ " {} function the length argument is {} exceeded
maximum default "
+ "value: {}."
+ "if you really need this length, you could change
the session variable "
+ "set repeat_max_num = xxx.",
+ get_name(), col_len_data[i],
context->state()->repeat_max_num());
+ }
// make compatible with mysql. return empty string if pad is
empty
if (pad_char_size == 0) {
diff --git a/regression-test/data/query_p1/test_big_pad.out
b/regression-test/data/query_p1/test_big_pad.out
new file mode 100644
index 00000000000..5c622cdf66c
--- /dev/null
+++ b/regression-test/data/query_p1/test_big_pad.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql_rpad --
+15000
+
diff --git a/regression-test/suites/query_p1/test_big_pad.groovy
b/regression-test/suites/query_p1/test_big_pad.groovy
index 635881dc80d..b96a380ac8b 100644
--- a/regression-test/suites/query_p1/test_big_pad.groovy
+++ b/regression-test/suites/query_p1/test_big_pad.groovy
@@ -30,11 +30,18 @@ suite("test_big_pad") {
distributed BY hash(k1) buckets 3
properties("replication_num" = "1");
"""
+ test {
+ sql "select rpad('a',15000,'asd');"
+ exception "rpad function the length argument is 15000 exceeded maximum
default value"
+ }
+ sql """ set repeat_max_num = 2000000001 """ // default value is 10000
+ qt_sql_rpad"select length(rpad('a',15000,'asd'));"
sql "insert into d_table
values(1,2000000000,1,'a'),(1,2000000000,1,'a'),(1,2000000000,1,'a');"
test {
sql "select
rpad('a',k2,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') from
d_table;"
exception "string column length is too large"
}
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]