Skip to content

Commit

Permalink
[Refactor] Chop too large hyperscan regex pattern when logging it on …
Browse files Browse the repository at this point in the history
…an error (StarRocks#52467)

Signed-off-by: satanson <[email protected]>
  • Loading branch information
satanson authored and ZiheLiu committed Oct 31, 2024
1 parent cce448a commit 23752f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion be/src/exprs/like_predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ bool LikePredicate::hs_compile_and_alloc_scratch(const std::string& pattern, Lik
if (hs_compile(pattern.c_str(), HS_FLAG_ALLOWEMPTY | HS_FLAG_DOTALL | HS_FLAG_UTF8 | HS_FLAG_SINGLEMATCH,
HS_MODE_BLOCK, nullptr, &state->database, &state->compile_err) != HS_SUCCESS) {
std::stringstream error;
error << "Invalid hyperscan expression: " << std::string(slice.data, slice.size) << ": "
auto chopped_size = std::min<size_t>(slice.size, 64);
auto ellipsis = (chopped_size < slice.size) ? "..." : "";
error << "Invalid hyperscan expression: " << std::string(slice.data, chopped_size) << ellipsis << ": "
<< state->compile_err->message << PROMPT_INFO;
LOG(WARNING) << error.str().c_str();
hs_free_compile_error(state->compile_err);
Expand Down

0 comments on commit 23752f6

Please sign in to comment.