Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <[email protected]>
  • Loading branch information
hawkingrei committed Nov 15, 2024
1 parent 177870f commit 372b4ba
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/planner/core/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -1994,14 +1994,16 @@ func (p *preprocessor) skipLockMDL() bool {
return p.flag&inImportInto > 0 || p.flag&inAnalyze > 0
}

type aliasChecker struct {
}
// aliasChecker is used to check the alias of the table in delete statement.
//
// for example: delete tt1 from t1 tt1,(select max(id) id from t2)tt2 where tt1.id<=tt2.id
// `delete tt1```` will be transfer to `delete current_database.t1` in default.
// because `tt1` cannot be used as alias in delete statement.
// so we have to set `tt1` as alias by aliasChecker.
type aliasChecker struct{}

func (e *aliasChecker) Enter(in ast.Node) (ast.Node, bool) {
if deleteStmt, ok := in.(*ast.DeleteStmt); ok {
// delete tt1 from t1 tt1,(select max(id) id from t2)tt2 where tt1.id<=tt2.id
// you should set tt1 as alias.

// 1. check the tableRefs of deleteStmt
var aliases []*pmodel.CIStr
if deleteStmt.TableRefs != nil && deleteStmt.TableRefs.TableRefs != nil {
Expand All @@ -2022,6 +2024,7 @@ func (e *aliasChecker) Enter(in ast.Node) (ast.Node, bool) {
for _, alias := range aliases {
if table.Name.L == alias.L {
table.IsAlias = true
break
}
}
}
Expand Down

0 comments on commit 372b4ba

Please sign in to comment.