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 (backport #52467) (#52528)

Co-authored-by: satanson <[email protected]>
  • Loading branch information
mergify[bot] and satanson authored Nov 1, 2024
1 parent 4265738 commit 2208752
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion be/src/exprs/vectorized/like_predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,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 2208752

Please sign in to comment.