Xianqing He created IMPALA-15547:
------------------------------------

             Summary: Fix LIKE pattern truncation at embedded NUL bytes
                 Key: IMPALA-15547
                 URL: https://issues.apache.org/jira/browse/IMPALA-15547
             Project: IMPALA
          Issue Type: Bug
          Components: Backend
    Affects Versions: Impala 5.0.0
            Reporter: Xianqing He


h3. Problem

IMPALA-12374 optimized constant LIKE/ILIKE patterns with leading/trailing {{%}} 
wildcards by trimming them and switching to anchored partial regex matching. 
The pattern conversions introduced there used the null-terminated 
{{StringVal(const char*)}} constructor, which computes the length with 
{{strlen()}}. As a result, a constant pattern containing an embedded NUL byte 
(valid in STRING values) is silently truncated at the first NUL before 
{{ConvertLikePattern()}} compiles the regex, producing wrong results.

Example: {{LIKE 'a%<NUL>b'}} is truncated to {{a%}}, so the value {{'ax'}} 
incorrectly matches.

h3. Fix

Use the length-aware {{StringVal(uint8_t*, int)}} constructor in 
{{LikePredicate::OptimizeConstantPatternMatch()}} for both the raw and the 
trimmed pattern, preserving every byte.

h3. Testing

Added regression tests in {{be/src/exprs/like-predicate-test.cc}} covering an 
untrimmed pattern ({{a%<NUL>b}}) and a pattern trimmed on both sides 
({{%a<NUL>_%}}), each with matching and non-matching values, in case-sensitive 
and case-insensitive (ILIKE) modes. Verified the tests fail before the fix and 
pass after; {{TestLikePredicate.RegexMatchOptimization}} still passes.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to