@@ -66,9 +66,10 @@ func (p *DeletePlan) Execute(ctx context.Context, hints ...*ast.TableOptimizerHi
6666 return nil , 0 , errors .WithStack (err )
6767 }
6868 }
69+ schema := proto .Schema (ctx )
6970 for _ , table := range p .Tables {
7071 sb .Reset ()
71- if err = p .generate (& sb , table , hints ... ); err != nil {
72+ if err = p .generate (& sb , schema , table , hints ... ); err != nil {
7273 return nil , 0 , errors .Wrap (err , "failed to generate sql for delete" )
7374 }
7475 sql := sb .String ()
@@ -114,7 +115,7 @@ func (p *DeletePlan) Execute(ctx context.Context, hints ...*ast.TableOptimizerHi
114115 return mysqlResult , warnings , nil
115116}
116117
117- func (p * DeletePlan ) generate (sb * strings.Builder , table string , hints ... * ast.TableOptimizerHint ) error {
118+ func (p * DeletePlan ) generate (sb * strings.Builder , schema , table string , hints ... * ast.TableOptimizerHint ) error {
118119 ctx := format .NewRestoreCtx (constant .DBPackRestoreFormat , sb )
119120 ctx .WriteKeyWord ("DELETE " )
120121
@@ -133,7 +134,7 @@ func (p *DeletePlan) generate(sb *strings.Builder, table string, hints ...*ast.T
133134 }
134135
135136 ctx .WriteKeyWord ("FROM " )
136- ctx .WritePlain ( table )
137+ ctx .WritePlainf ( "%s.%s" , schema , table )
137138 if p .Stmt .Where != nil {
138139 ctx .WriteKeyWord (" WHERE " )
139140 if err := p .Stmt .Where .Restore (ctx ); err != nil {
0 commit comments