linter: enable revive for session (#43420)

ref pingcap/tidb#40786
This commit is contained in:
Weizhen Wang
2023-04-26 13:53:52 +08:00
committed by GitHub
parent a64b149fa2
commit 7c5e7ea851
6 changed files with 14 additions and 13 deletions

View File

@ -500,6 +500,7 @@
"dumpling/export": "dumpling/export code",
"lock/": "lock file",
"errno/": "errno code",
"session/": "session code",
"structure/": "structure code",
"telemetry/": "telemetry code",
"parser/": "parser code",

View File

@ -2430,7 +2430,7 @@ func upgradeToVer136(s Session, ver int64) {
doReentrantDDL(s, fmt.Sprintf("ALTER TABLE mysql.%s ADD INDEX idx_task_key(task_key)", ddl.BackgroundSubtaskTable), dbterror.ErrDupKeyName)
}
func upgradeToVer137(s Session, ver int64) {
func upgradeToVer137(_ Session, _ int64) {
// NOOP, we don't depend on ddl to init the default group due to backward compatible issue.
}

View File

@ -720,7 +720,7 @@ func (c *cachedTableRenewLease) start(ctx context.Context) error {
return err
}
func (c *cachedTableRenewLease) stop(ctx context.Context) {
func (c *cachedTableRenewLease) stop(_ context.Context) {
close(c.exit)
}
@ -1152,7 +1152,7 @@ func (s *session) isInternal() bool {
return s.sessionVars.InRestrictedSQL
}
func (s *session) isTxnRetryableError(err error) bool {
func (*session) isTxnRetryableError(err error) bool {
if atomic.LoadUint32(&SchemaChangedWithoutRetry) == 1 {
return kv.IsTxnRetryableError(err)
}
@ -2395,7 +2395,7 @@ func runStmt(ctx context.Context, se *session, s sqlexec.Statement) (rs sqlexec.
type ExecStmtVarKeyType int
// String defines a Stringer function for debugging and pretty printing.
func (k ExecStmtVarKeyType) String() string {
func (ExecStmtVarKeyType) String() string {
return "exec_stmt_var_key"
}
@ -2977,7 +2977,7 @@ func (s *session) AuthWithoutVerification(user *auth.UserIdentity) bool {
}
// RefreshVars implements the sessionctx.Context interface.
func (s *session) RefreshVars(ctx context.Context) error {
func (s *session) RefreshVars(_ context.Context) error {
pruneMode, err := s.GetSessionVars().GlobalVarsAccessor.GetGlobalSysVar(variable.TiDBPartitionPruneMode)
if err != nil {
return err
@ -3800,8 +3800,7 @@ func (s *session) ShowProcess() *util.ProcessInfo {
}
// GetStartTSFromSession returns the startTS in the session `se`
func GetStartTSFromSession(se interface{}) (uint64, uint64) {
var startTS, processInfoID uint64
func GetStartTSFromSession(se interface{}) (startTS, processInfoID uint64) {
tmp, ok := se.(*session)
if !ok {
logutil.BgLogger().Error("GetStartTSFromSession failed, can't transform to session struct")
@ -4174,7 +4173,8 @@ func (s *session) SetMemoryFootprintChangeHook() {
}
// EncodeSessionStates implements SessionStatesHandler.EncodeSessionStates interface.
func (s *session) EncodeSessionStates(ctx context.Context, sctx sessionctx.Context, sessionStates *sessionstates.SessionStates) error {
func (s *session) EncodeSessionStates(ctx context.Context,
_ sessionctx.Context, sessionStates *sessionstates.SessionStates) error {
// Transaction status is hard to encode, so we do not support it.
s.txn.mu.Lock()
valid := s.txn.Valid()
@ -4242,7 +4242,8 @@ func (s *session) EncodeSessionStates(ctx context.Context, sctx sessionctx.Conte
}
// DecodeSessionStates implements SessionStatesHandler.DecodeSessionStates interface.
func (s *session) DecodeSessionStates(ctx context.Context, sctx sessionctx.Context, sessionStates *sessionstates.SessionStates) error {
func (s *session) DecodeSessionStates(ctx context.Context,
_ sessionctx.Context, sessionStates *sessionstates.SessionStates) error {
// Decode prepared statements and sql bindings.
for _, handler := range s.sessionStatesHandlers {
if err := handler.DecodeSessionStates(ctx, s, sessionStates); err != nil {

View File

@ -339,7 +339,7 @@ func GetHistory(ctx sessionctx.Context) *StmtHistory {
}
// GetRows4Test gets all the rows from a RecordSet, only used for test.
func GetRows4Test(ctx context.Context, sctx sessionctx.Context, rs sqlexec.RecordSet) ([]chunk.Row, error) {
func GetRows4Test(ctx context.Context, _ sessionctx.Context, rs sqlexec.RecordSet) ([]chunk.Row, error) {
if rs == nil {
return nil, nil
}

View File

@ -258,8 +258,7 @@ func (txn *LazyTxn) GoString() string {
// GetOption implements the GetOption
func (txn *LazyTxn) GetOption(opt int) interface{} {
if txn.Transaction == nil {
switch opt {
case kv.TxnScope:
if opt == kv.TxnScope {
return ""
}
return nil

View File

@ -159,4 +159,4 @@ func (recorder *TrxHistoryRecorder) ResizeSummaries(capacity uint) {
}
// Recorder is the recorder instance.
var Recorder TrxHistoryRecorder = newTrxHistoryRecorder(0)
var Recorder = newTrxHistoryRecorder(0)