Skip to content

Commit 08fc72a

Browse files
committed
only DMLMustMatchLeftMostPrefix check single index
1 parent 231e762 commit 08fc72a

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

sqle/driver/mysql/rule/rule.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5362,9 +5362,6 @@ func isColumnMatchedALeftMostPrefix(allCols []string, colsWithEQ, colsWithOr []s
53625362
multiConstraints := make([]*ast.Constraint, 0)
53635363
for _, constraint := range constraints {
53645364
if len(constraint.Keys) == 1 {
5365-
if checkSingleIndex(allCols, constraint) {
5366-
return true
5367-
}
53685365
continue
53695366
}
53705367
multiConstraints = append(multiConstraints, constraint)
@@ -5393,6 +5390,16 @@ func isColumnMatchedALeftMostPrefix(allCols []string, colsWithEQ, colsWithOr []s
53935390
return true
53945391
}
53955392

5393+
func checkSingleIndex(allCols []string, constraint *ast.Constraint) bool {
5394+
singleIndexColumn := constraint.Keys[0].Column.Name.L
5395+
for _, col := range allCols {
5396+
if col == singleIndexColumn {
5397+
return true
5398+
}
5399+
}
5400+
return false
5401+
}
5402+
53965403
func isColumnUseLeftMostPrefix(allCols []string, constraints []*ast.Constraint) bool {
53975404
multiConstraints := make([]*ast.Constraint, 0)
53985405
for _, constraint := range constraints {
@@ -5429,16 +5436,6 @@ func isColumnUseLeftMostPrefix(allCols []string, constraints []*ast.Constraint)
54295436
return true
54305437
}
54315438

5432-
func checkSingleIndex(allCols []string, constraint *ast.Constraint) bool {
5433-
singleIndexColumn := constraint.Keys[0].Column.Name.L
5434-
for _, col := range allCols {
5435-
if col == singleIndexColumn {
5436-
return true
5437-
}
5438-
}
5439-
return false
5440-
}
5441-
54425439
func checkJoinFieldUseIndex(input *RuleHandlerInput) error {
54435440
isUsingIndex, err := judgeJoinFieldUseIndex(input)
54445441
if err == nil && !isUsingIndex {

0 commit comments

Comments
 (0)