-
Notifications
You must be signed in to change notification settings - Fork 6.2k
planner: rewrite FTS predicates to LIKE for evaluation of non-TiCI query plan #65626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
a5a6400
4ded0d5
5051049
a11e436
3379ed5
ba0f3d7
82416d8
f7b1fa5
c63c6bb
0c74944
dbdbce1
dc10c79
48373d1
2121e81
0b4ba84
69b1497
04b00aa
ab11dda
c9e0409
8ba9a8a
19e9dc3
569f3aa
19aba2c
eb1d412
4200060
a566282
afcf285
d5cfdcb
4080f42
c22f54c
b7733c7
e603043
1ddbcca
dc2cccb
98e97fd
32b7c04
bac401f
4aa6f93
49db4da
3647abe
8803614
b0b04c4
aba6e18
57f98c4
a18872c
ed3e7a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1692,6 +1692,8 @@ func (er *expressionRewriter) Leave(originInNode ast.Node) (retNode ast.Node, ok | |||||||||||||||||||||
| } | ||||||||||||||||||||||
| er.ctxStack[len(er.ctxStack)-1].SetCoercibility(expression.CoercibilityExplicit) | ||||||||||||||||||||||
| er.ctxStack[len(er.ctxStack)-1].SetCharsetAndCollation(arg.GetType(er.sctx.GetEvalCtx()).GetCharset(), arg.GetType(er.sctx.GetEvalCtx()).GetCollate()) | ||||||||||||||||||||||
| case *ast.MatchAgainst: | ||||||||||||||||||||||
| er.matchAgainstToExpression(v) | ||||||||||||||||||||||
| default: | ||||||||||||||||||||||
| er.err = errors.Errorf("UnknownType: %T", v) | ||||||||||||||||||||||
| return retNode, false | ||||||||||||||||||||||
|
|
@@ -2217,6 +2219,71 @@ func (er *expressionRewriter) patternLikeOrIlikeToExpression(v *ast.PatternLikeO | |||||||||||||||||||||
| er.ctxStackAppend(function, types.EmptyName) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func (er *expressionRewriter) matchAgainstToExpression(v *ast.MatchAgainst) { | ||||||||||||||||||||||
| // Check the session variable to determine behavior | ||||||||||||||||||||||
| var fallbackMode string | ||||||||||||||||||||||
| if er.planCtx != nil && er.planCtx.builder != nil && er.planCtx.builder.ctx != nil { | ||||||||||||||||||||||
| fallbackMode = er.planCtx.builder.ctx.GetSessionVars().FulltextSearchFallback | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| fallbackMode = "like" // default | ||||||||||||||||||||||
|
||||||||||||||||||||||
| var fallbackMode string | |
| if er.planCtx != nil && er.planCtx.builder != nil && er.planCtx.builder.ctx != nil { | |
| fallbackMode = er.planCtx.builder.ctx.GetSessionVars().FulltextSearchFallback | |
| } else { | |
| fallbackMode = "like" // default | |
| fallbackMode := "like" // default | |
| if er.planCtx != nil && er.planCtx.builder != nil && er.planCtx.builder.ctx != nil { | |
| if sv := er.planCtx.builder.ctx.GetSessionVars(); sv != nil { | |
| fallbackMode = sv.FulltextSearchFallback | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test appears inconsistent with the implementation logic. The table at line 198 has a FULLTEXT INDEX on the title column. According to the logic in expression_rewriter.go lines 2234-2238, when a fulltext index exists, MATCH...AGAINST should always return an error "MATCH...AGAINST with fulltext index (native fulltext search not supported)", regardless of the fallback mode setting. However, line 211 expects the query to succeed with the default 'like' fallback mode. Either the test expectations are incorrect, or the hasFulltextIndex function is not properly detecting the index in this test environment.