planner: drop procedure (#60670)

close pingcap/tidb#60669
This commit is contained in:
Daniël van Eeden
2025-04-21 04:42:58 +02:00
committed by GitHub
parent 99fcfadcdc
commit f00fe4db0c
3 changed files with 15 additions and 2 deletions

View File

@ -2406,6 +2406,11 @@ error = '''
The target table %-.100s of the %s is not updatable
'''
["planner:1305"]
error = '''
%s %s does not exist
'''
["planner:1345"]
error = '''
EXPLAIN/SHOW can not be issued; lacking privileges for underlying table

View File

@ -559,7 +559,7 @@ func (b *PlanBuilder) Build(ctx context.Context, node *resolve.NodeW) (base.Plan
*ast.GrantStmt, *ast.DropUserStmt, *ast.AlterUserStmt, *ast.AlterRangeStmt, *ast.RevokeStmt, *ast.KillStmt, *ast.DropStatsStmt,
*ast.GrantRoleStmt, *ast.RevokeRoleStmt, *ast.SetRoleStmt, *ast.SetDefaultRoleStmt, *ast.ShutdownStmt,
*ast.RenameUserStmt, *ast.NonTransactionalDMLStmt, *ast.SetSessionStatesStmt, *ast.SetResourceGroupStmt,
*ast.ImportIntoActionStmt, *ast.CalibrateResourceStmt, *ast.AddQueryWatchStmt, *ast.DropQueryWatchStmt:
*ast.ImportIntoActionStmt, *ast.CalibrateResourceStmt, *ast.AddQueryWatchStmt, *ast.DropQueryWatchStmt, *ast.DropProcedureStmt:
return b.buildSimple(ctx, node.Node.(ast.StmtNode))
case ast.DDLNode:
return b.buildDDL(ctx, x)
@ -580,7 +580,7 @@ func (b *PlanBuilder) Build(ctx context.Context, node *resolve.NodeW) (base.Plan
case *ast.RecommendIndexStmt:
return b.buildRecommendIndex(x)
}
return nil, plannererrors.ErrUnsupportedType.GenWithStack("Unsupported type %T", node)
return nil, plannererrors.ErrUnsupportedType.GenWithStack("Unsupported type %T", node.Node)
}
func (b *PlanBuilder) buildSetConfig(ctx context.Context, v *ast.SetConfigStmt) (base.Plan, error) {
@ -3752,6 +3752,13 @@ func (b *PlanBuilder) buildSimple(ctx context.Context, node ast.StmtNode) (base.
err := plannererrors.ErrSpecificAccessDenied.GenWithStackByArgs("SUPER or RESOURCE_GROUP_ADMIN or RESOURCE_GROUP_USER")
b.visitInfo = appendDynamicVisitInfo(b.visitInfo, []string{"RESOURCE_GROUP_ADMIN", "RESOURCE_GROUP_USER"}, false, err)
}
case *ast.DropProcedureStmt:
procName := fmt.Sprintf("%s.%s", ast.NewCIStr(b.ctx.GetSessionVars().CurrentDB).O, raw.ProcedureName.Name.O)
err := plannererrors.ErrSpDoesNotExist.GenWithStackByArgs("PROCEDURE", procName)
if !raw.IfExists {
return nil, err
}
b.ctx.GetSessionVars().StmtCtx.AppendNote(err)
}
return p, nil
}

View File

@ -120,4 +120,5 @@ var (
ErrPrepareDDL = dbterror.ClassExecutor.NewStd(mysql.ErrPrepareDDL)
ErrRowIsReferenced2 = dbterror.ClassOptimizer.NewStd(mysql.ErrRowIsReferenced2)
ErrNoReferencedRow2 = dbterror.ClassOptimizer.NewStd(mysql.ErrNoReferencedRow2)
ErrSpDoesNotExist = dbterror.ClassOptimizer.NewStd(mysql.ErrSpDoesNotExist)
)