-
Notifications
You must be signed in to change notification settings - Fork 6k
planner: fix that vector index output empty result when pk is non-int type #57629
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 6 commits
38e74df
6c41ea2
ec3fb7b
2ba6fda
eca8aca
ccb08e7
d08472b
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 |
---|---|---|
|
@@ -5502,7 +5502,10 @@ func (b *PlanBuilder) buildUpdate(ctx context.Context, update *ast.UpdateStmt) ( | |
if dbName == "" { | ||
dbName = b.ctx.GetSessionVars().CurrentDB | ||
} | ||
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.SelectPriv, dbName, t.Name.L, "", nil) | ||
// Avoid adding CTE table to the SELECT privilege list, maybe we have better way to do this? | ||
if _, ok := b.nameMapCTE[t.Name.L]; !ok { | ||
b.visitInfo = appendVisitInfo(b.visitInfo, mysql.SelectPriv, dbName, t.Name.L, "", nil) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why should we need this for? any direct effect from the issue? |
||
} | ||
|
||
oldSchemaLen := p.Schema().Len() | ||
|
@@ -7406,12 +7409,12 @@ func (b *PlanBuilder) genCTETableNameForError() string { | |
|
||
func (b *PlanBuilder) buildWith(ctx context.Context, w *ast.WithClause) ([]*cteInfo, error) { | ||
// Check CTE name must be unique. | ||
nameMap := make(map[string]struct{}) | ||
b.nameMapCTE = make(map[string]struct{}) | ||
for _, cte := range w.CTEs { | ||
if _, ok := nameMap[cte.Name.L]; ok { | ||
if _, ok := b.nameMapCTE[cte.Name.L]; ok { | ||
return nil, plannererrors.ErrNonUniqTable | ||
} | ||
nameMap[cte.Name.L] = struct{}{} | ||
b.nameMapCTE[cte.Name.L] = struct{}{} | ||
} | ||
ctes := make([]*cteInfo, 0, len(w.CTEs)) | ||
for _, cte := range w.CTEs { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,8 +269,10 @@ type PlanBuilder struct { | |
allocIDForCTEStorage int | ||
buildingRecursivePartForCTE bool | ||
buildingCTE bool | ||
//Check whether the current building query is a CTE | ||
// Check whether the current building query is a CTE | ||
isCTE bool | ||
// CTE table name in lower case, it can be nil | ||
nameMapCTE map[string]struct{} | ||
|
||
// subQueryCtx and subQueryHintFlags are for handling subquery related hints. | ||
// Note: "subquery" here only contains subqueries that are handled by the expression rewriter, i.e., [NOT] IN, | ||
|
@@ -1191,15 +1193,19 @@ func getPossibleAccessPaths(ctx base.PlanContext, tableHints *hint.PlanHints, in | |
continue | ||
} | ||
} | ||
path := &util.AccessPath{Index: index} | ||
if index.VectorInfo != nil { | ||
// Because the value of `TiFlashReplica.Available` changes as the user modify replica, it is not ideal if the state of index changes accordingly. | ||
// So the current way to use the vector indexes is to require the TiFlash Replica to be available. | ||
if !tblInfo.TiFlashReplica.Available { | ||
continue | ||
} | ||
path := genTiFlashPath(tblInfo) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel that the original logic is different here set up "tablePath. IsCommonHandlePath = true". What does this setting do? Why is the original logic not needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A normal index will create the index's ranges. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
path.StoreType = kv.TiFlash | ||
path.Index = index | ||
publicPaths = append(publicPaths, path) | ||
continue | ||
} | ||
path := &util.AccessPath{Index: index} | ||
publicPaths = append(publicPaths, path) | ||
} | ||
} | ||
|
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.
I changed it to the highest priority.
Because when for the vector index path, the
IsIntHandlePath
can also be true. We need to use a new way to check the real pk path.