fix(query): avoid planner panic for invalid LIKE ESCAPE literals#19597
fix(query): avoid planner panic for invalid LIKE ESCAPE literals#19597sundy-li wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c3a372e77
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let escape_char = Self::validate_like_escape(span, escape)?; | ||
| let new_like_str = if let Some(escape_char) = escape_char { | ||
| Cow::Owned(convert_escape_pattern(like_str, escape_char)) |
There was a problem hiding this comment.
Validate ESCAPE in LIKE subquery comparisons too
This new check only runs through resolve_like/resolve_like_escape. Expr::LikeSubquery still goes through resolve_scalar_subquery (type_check.rs:1315-1327,1601-1613), which converts BinaryOperator::Like(escape) straight into SubqueryComparisonOp::Like without validating the literal, and the runtime LIKE path in comparison.rs:1263-1268 just uses the first character (or ignores an empty string). So queries such as SELECT 'a' LIKE ANY (SELECT 'a') ESCAPE 'ab' or ... ESCAPE '' are still accepted instead of raising the new semantic error, leaving this fix incomplete for subquery forms.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Validated LIKE ESCAPE in resolve_scalar_subquery before building SubqueryComparisonOp::Like, and added planner coverage for invalid LIKE ANY (SELECT ...) ESCAPE literals (`` and ab).
sundy-li
left a comment
There was a problem hiding this comment.
The new validate_like_escape helper only runs through resolve_like and resolve_like_escape. LIKE ... (subquery) ESCAPE ... still goes through resolve_scalar_subquery -> SubqueryComparisonOp::Like without validating the escape literal, so queries like SELECT a LIKE ANY (SELECT a) ESCAPE or ... ESCAPE ab are still accepted instead of returning the new semantic error. Please validate the escape before constructing the subquery comparison and add a regression for a subquery form.
🤖 CI Job Analysis
📊 Summary
❌ NO RETRY NEEDEDAll failures appear to be code/test issues requiring manual fixes. 🔍 Job Details
🤖 AboutAutomated analysis using job annotations to distinguish infrastructure issues (auto-retried) from code/test issues (manual fixes needed). |
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
Fixes #19562
LIKE/NOT LIKE/LIKE ANY ... ESCAPEliterals during planner type checking so invalid escape strings return a semantic error instead of panickingESCAPEliteralsTests
Type of change
This change is