diff --git a/domain/plan_replayer.go b/domain/plan_replayer.go index 8bbc26cf79ec2..bb36048f02b26 100644 --- a/domain/plan_replayer.go +++ b/domain/plan_replayer.go @@ -147,8 +147,8 @@ func insertPlanReplayerStatus(ctx context.Context, sctx sessionctx.Context, reco } func insertPlanReplayerErrorStatusRecord(ctx context.Context, sctx sessionctx.Context, instance string, record PlanReplayerStatusRecord) { - exec := sctx.(sqlexec.SQLExecutor) - _, err := exec.ExecuteInternal(ctx, fmt.Sprintf( + exec := sctx.(sqlexec.RestrictedSQLExecutor) + _, _, err := exec.ExecRestrictedSQL(ctx, nil, fmt.Sprintf( "insert into mysql.plan_replayer_status (sql_digest, plan_digest, origin_sql, fail_reason, instance) values ('%s','%s','%s','%s','%s')", record.SQLDigest, record.PlanDigest, record.OriginSQL, record.FailedReason, instance)) if err != nil { @@ -158,8 +158,8 @@ func insertPlanReplayerErrorStatusRecord(ctx context.Context, sctx sessionctx.Co } func insertPlanReplayerSuccessStatusRecord(ctx context.Context, sctx sessionctx.Context, instance string, record PlanReplayerStatusRecord) { - exec := sctx.(sqlexec.SQLExecutor) - _, err := exec.ExecuteInternal(ctx, fmt.Sprintf( + exec := sctx.(sqlexec.RestrictedSQLExecutor) + _, _, err := exec.ExecRestrictedSQL(ctx, nil, fmt.Sprintf( "insert into mysql.plan_replayer_status (sql_digest, plan_digest, origin_sql, token, instance) values ('%s','%s','%s','%s','%s')", record.SQLDigest, record.PlanDigest, record.OriginSQL, record.Token, instance)) if err != nil { @@ -167,7 +167,7 @@ func insertPlanReplayerSuccessStatusRecord(ctx context.Context, sctx sessionctx. zap.String("sql", record.OriginSQL), zap.Error(err)) // try insert record without original sql - _, err = exec.ExecuteInternal(ctx, fmt.Sprintf( + _, _, err = exec.ExecRestrictedSQL(ctx, nil, fmt.Sprintf( "insert into mysql.plan_replayer_status (sql_digest, plan_digest, token, instance) values ('%s','%s','%s','%s')", record.SQLDigest, record.PlanDigest, record.Token, instance)) if err != nil { diff --git a/executor/plan_replayer.go b/executor/plan_replayer.go index e5b745b081b66..f8a7ffe90fcca 100644 --- a/executor/plan_replayer.go +++ b/executor/plan_replayer.go @@ -108,8 +108,8 @@ func (e *PlanReplayerExec) Next(ctx context.Context, req *chunk.Chunk) error { func (e *PlanReplayerExec) removeCaptureTask(ctx context.Context) error { ctx1 := kv.WithInternalSourceType(ctx, kv.InternalTxnStats) - exec := e.ctx.(sqlexec.SQLExecutor) - _, err := exec.ExecuteInternal(ctx1, fmt.Sprintf("delete from mysql.plan_replayer_task where sql_digest = '%s' and plan_digest = '%s'", + exec := e.ctx.(sqlexec.RestrictedSQLExecutor) + _, _, err := exec.ExecRestrictedSQL(ctx1, nil, fmt.Sprintf("delete from mysql.plan_replayer_task where sql_digest = '%s' and plan_digest = '%s'", e.CaptureInfo.SQLDigest, e.CaptureInfo.PlanDigest)) if err != nil { logutil.BgLogger().Warn("remove mysql.plan_replayer_status record failed", @@ -134,8 +134,8 @@ func (e *PlanReplayerExec) registerCaptureTask(ctx context.Context) error { if exists { return errors.New("plan replayer capture task already exists") } - exec := e.ctx.(sqlexec.SQLExecutor) - _, err = exec.ExecuteInternal(ctx1, fmt.Sprintf("insert into mysql.plan_replayer_task (sql_digest, plan_digest) values ('%s','%s')", + exec := e.ctx.(sqlexec.RestrictedSQLExecutor) + _, _, err = exec.ExecRestrictedSQL(ctx1, nil, fmt.Sprintf("insert into mysql.plan_replayer_task (sql_digest, plan_digest) values ('%s','%s')", e.CaptureInfo.SQLDigest, e.CaptureInfo.PlanDigest)) if err != nil { logutil.BgLogger().Warn("insert mysql.plan_replayer_status record failed", diff --git a/privilege/privileges/privileges.go b/privilege/privileges/privileges.go index c31d0df65cd08..36b07c6e47b5e 100644 --- a/privilege/privileges/privileges.go +++ b/privilege/privileges/privileges.go @@ -142,13 +142,6 @@ func (p *UserPrivileges) RequestVerification(activeRoles []*auth.RoleIdentity, d dbLowerName := strings.ToLower(db) tblLowerName := strings.ToLower(table) - /// Skip check for plan replayer related table - if util.IsSysDB(dbLowerName) { - if util.IsPlanReplayerTable(tblLowerName) { - return true - } - } - // If SEM is enabled and the user does not have the RESTRICTED_TABLES_ADMIN privilege // There are some hard rules which overwrite system tables and schemas as read-only at most. semEnabled := sem.IsEnabled() diff --git a/util/misc.go b/util/misc.go index 982015ac7a6be..d336aa5765451 100644 --- a/util/misc.go +++ b/util/misc.go @@ -209,15 +209,6 @@ func IsSysDB(dbLowerName string) bool { return dbLowerName == mysql.SystemDB } -// IsPlanReplayerTable checks whether is plan replayer related table -func IsPlanReplayerTable(tblLowerName string) bool { - switch tblLowerName { - case "plan_replayer_status", "plan_replayer_task": - return true - } - return false -} - // IsSystemView is similar to IsMemOrSyDB, but does not include the mysql schema func IsSystemView(dbLowerName string) bool { switch dbLowerName {