Repository navigation
Closed
Labels
kind/bugSomething isn't workingkind/featurephase/testingpriority/p1Medium priority feature that should be implemented in this version
Milestone
Description
Description
MatrixOne does not support the LIKE ... ESCAPE syntax for specifying custom escape characters in LIKE pattern matching. When attempting to use the ESCAPE clause, MatrixOne returns a SQL syntax error.
Error Message
ERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error near "ESCAPE"
Affected Cases
This issue affects 1 test case from our boundary testing on the industry_radar_test database.
Failing SQL Statements
Example 1: LIKE with ESCAPE
SELECT * FROM company WHERE full_name LIKE '%\%' ESCAPE '' LIMIT 10;Error: ERROR 1064 (HY000): SQL parser error: syntax error near "ESCAPE"
Expected Behavior
In MySQL, the LIKE ... ESCAPE syntax is fully supported. It allows you to specify a custom escape character for pattern matching, which is useful when you need to match literal special characters.
Example MySQL syntax:
-- Match strings containing literal '%'
SELECT * FROM table WHERE column LIKE '%\%' ESCAPE '\';
-- Match strings containing literal '_'
SELECT * FROM table WHERE column LIKE '%\_' ESCAPE '\';
-- Custom escape character
SELECT * FROM table WHERE column LIKE '%#%' ESCAPE '#';Impact
- MySQL Compatibility: LIKE ESCAPE is a standard MySQL feature
- Functionality: Users cannot match literal special characters in LIKE patterns
- Migration: Applications using LIKE ESCAPE will fail when migrating to MatrixOne
- Workaround: Users must use alternative methods (e.g., REGEXP) which may have different semantics
Use Cases
LIKE ESCAPE is commonly used for:
- Matching Literal Special Characters: Matching strings that contain literal '%' or '_' characters
- Custom Escape Sequences: Using custom escape characters for specific pattern matching needs
- Data Validation: Validating data that may contain special characters
Workaround
As a temporary workaround, users can:
- Use REGEXP instead of LIKE (if the pattern is simple enough)
- Use string functions to escape special characters before matching
- Use application-level pattern processing
However, these workarounds:
- May have different semantics
- May be less efficient
- May not be equivalent in all cases
Suggested Fix
- Parser Update: Update the SQL parser to recognize the ESCAPE clause in LIKE expressions
- Pattern Processing: Implement escape character processing in LIKE pattern matching
- Documentation: Update documentation to reflect support for LIKE ESCAPE
- Testing: Add comprehensive tests for various ESCAPE scenarios
Related MySQL Documentation
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't workingkind/featurephase/testingpriority/p1Medium priority feature that should be implemented in this version
Activity
support LIKE ... ESCAPE syntax (matrixorigin#23104)
add BVT test for LIKE ... ESCAPE syntax (matrixorigin#23104)
support LIKE ... ESCAPE syntax (matrixorigin#23104)
add BVT test for LIKE ... ESCAPE syntax (matrixorigin#23104)
Ariznawlll commentedon Jul 2, 2026
Updated verification on latest
main(0e8602b78) against MySQL 8.0.45:The parser now accepts
LIKE ... ESCAPE, but behavior is still not MySQL-compatible.MySQL result:
MatrixOne result:
So this issue is no longer just "syntax not supported"; it also needs runtime semantics for custom escape matching and validation of the ESCAPE argument length.
Ariznawlll commentedon Jul 22, 2026
最新
main回归补充(2026-07-22,基线c0486a2446c84c6dd6bf142494fe85243877ddc5):该问题还会使 prepared statement 的 ESCAPE 参数丢失。Incorrect arguments to EXECUTE。@pat时 MatrixOne 反而执行成功,说明 ESCAPE 后的参数没有进入 prepared 参数列表。s LIKE 'a\\_%' ESCAPE ?被识别为 0 个参数。代码路径也与现象一致:
ComparisonExpr保留EscapeAST,但bindComparisonExpr构造 LIKE 函数时只绑定Left和Right,没有绑定Escape。因此此 prepared 差异仍归属于本 issue,不另开重复单。VioletQwQ-0 commentedon Jul 30, 2026
QA handoff after merge of #26429.
QA Decision
7f8447f1daf8884fc06d9655e9a542f89c88fe55passed Ubuntu UT, arm64 SCA, UT coverage, PROXY BVT, PESSIMISTIC BVT, and Utils Coverage. Canonical coverage is intest/distributed/cases/operator/like_operator.sql.Merge evidence
11eaec8833e79b3b178ebeb9b6b2bb43fd6b679ePass expectation: supported direct and prepared ESCAPE expressions match MySQL results, NULL disables escaping without propagating NULL from the ESCAPE operand, and invalid explicit ESCAPE arguments return the expected error.
Fail expectation: any parser/binder parameter loss, custom/Unicode matching mismatch, SQL-mode mismatch, unexpected NULL result, or acceptance of invalid multi-character/row-dependent escapes should fail verification and be reported with the tested build and exact SQL/result.
VioletQwQ-0 commentedon Jul 30, 2026
Post-merge CI update for #26429:
7f8447f1daf8884fc06d9655e9a542f89c88fe55This provides deployed regression evidence for the merged head, but it does not replace the remaining MySQL compatibility checks listed in the QA handoff. The issue should remain open and assigned to QA until those direct/prepared ESCAPE scenarios receive an explicit PASS or FAIL result.
Ariznawlll commentedon Aug 5, 2026
测试版本
main607a9263616ea883ac02c052529d2aa4c62ac051原问题验证
原 LIKE ESCAPE 语句及标量等价断言在 MO/MySQL 各执行 3 次,普通自定义 escape、
%/_转义、空/NULL 边界均未再出现解析或错误结果问题。Happy Path 覆盖
%、_和 escape 字符自身,结果与 MySQL 一致。NO_BACKSLASH_ESCAPES模式均通过 3/3。Unhappy Path 覆盖
白盒验证
LIKE/ESCAPE、SQL mode 和 NULL escape 的 4 组聚焦 Go 测试通过。该路径不涉及并发生命周期,未执行
-race。回归测试
MatrixOne
test/distributed/cases/operator/like_operator.sql已覆盖 LIKE/ILIKE、escape、NULL、模式和错误路径,未重复加入 motr。测试结论
测试通过。
Ariznawlll commentedon Aug 5, 2026
motr 回归补充
已将本 issue 的公开 SQL 回归加入 motr PR #75:
issue_23104_like_escape.test0e8602b78cbfc13236ec3122f0ffb50f51ff61ef:prepared ESCAPE 参数丢失,执行返回Incorrect arguments to EXECUTE,用例失败。main@607a9263616ea883ac02c052529d2aa4c62ac051:连续 3 轮通过,69/69 条语句成功。完整
14_issue_regression执行结果为 143 success、2 configured skip、1 个无关既有失败(#25992,invalid allocation account)。Ariznawlll commentedon Aug 9, 2026
测试版本
main08770e1beeb23239c91165492f2fe85243a3c66a原问题验证
当前 main 的自定义
LIKE ... ESCAPE '#'可分别精确匹配字面%、_和 escape 自身;基本原始路径连续 3/3 与 MySQL 一致。Happy Path 覆盖
'%#%%' ESCAPE '#'仅匹配pct%literal。'%#_%' ESCAPE '#'仅匹配under_score。'%##%' ESCAPE '#'仅匹配hash#tag。Unhappy Path 覆盖
ESCAPE 'xx'以20301 Incorrect arguments to ESCAPE正常拒绝。白盒验证
不适用:parser 与运行时参数检查均由公开 SQL 和已有 prepared case 覆盖。
回归测试
已有
motr/suites/14_issue_regression/t/issue_23104_like_escape.test;当前 main 的14_issue_regressionsuite 中该 case 成功。此次未重复新增同功能文件。测试证据
测试结论
测试通过。