forked from pingcap/tidb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is an automated cherry-pick of pingcap#39932
Signed-off-by: ti-chi-bot <[email protected]>
- Loading branch information
1 parent
4b777b4
commit aaf15a7
Showing
17 changed files
with
2,853 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright 2022 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package sessionstates | ||
|
||
import ( | ||
"github.com/pingcap/tidb/errno" | ||
ptypes "github.com/pingcap/tidb/parser/types" | ||
"github.com/pingcap/tidb/sessionctx/stmtctx" | ||
"github.com/pingcap/tidb/types" | ||
"github.com/pingcap/tidb/util/dbterror" | ||
) | ||
|
||
// SessionStateType is the type of session states. | ||
type SessionStateType int | ||
|
||
var ( | ||
// ErrCannotMigrateSession indicates the session cannot be migrated. | ||
ErrCannotMigrateSession = dbterror.ClassSession.NewStd(errno.ErrCannotMigrateSession) | ||
) | ||
|
||
// These enums represents the types of session state handlers. | ||
const ( | ||
// StatePrepareStmt represents prepared statements. | ||
StatePrepareStmt SessionStateType = iota | ||
// StateBinding represents session SQL bindings. | ||
StateBinding | ||
) | ||
|
||
// PreparedStmtInfo contains the information about prepared statements, both text and binary protocols. | ||
type PreparedStmtInfo struct { | ||
Name string `json:"name,omitempty"` | ||
StmtText string `json:"text"` | ||
StmtDB string `json:"db,omitempty"` | ||
ParamTypes []byte `json:"types,omitempty"` | ||
} | ||
|
||
// QueryInfo represents the information of last executed query. It's used to expose information for test purpose. | ||
type QueryInfo struct { | ||
TxnScope string `json:"txn_scope"` | ||
StartTS uint64 `json:"start_ts"` | ||
ForUpdateTS uint64 `json:"for_update_ts"` | ||
ErrMsg string `json:"error,omitempty"` | ||
} | ||
|
||
// LastDDLInfo represents the information of last DDL. It's used to expose information for test purpose. | ||
type LastDDLInfo struct { | ||
Query string `json:"query"` | ||
SeqNum uint64 `json:"seq_num"` | ||
} | ||
|
||
// SessionStates contains all the states in the session that should be migrated when the session | ||
// is migrated to another server. It is shown by `show session_states` and recovered by `set session_states`. | ||
type SessionStates struct { | ||
UserVars map[string]*types.Datum `json:"user-var-values,omitempty"` | ||
UserVarTypes map[string]*ptypes.FieldType `json:"user-var-types,omitempty"` | ||
SystemVars map[string]string `json:"sys-vars,omitempty"` | ||
PreparedStmts map[uint32]*PreparedStmtInfo `json:"prepared-stmts,omitempty"` | ||
PreparedStmtID uint32 `json:"prepared-stmt-id,omitempty"` | ||
Status uint16 `json:"status,omitempty"` | ||
CurrentDB string `json:"current-db,omitempty"` | ||
LastTxnInfo string `json:"txn-info,omitempty"` | ||
LastQueryInfo *QueryInfo `json:"query-info,omitempty"` | ||
LastDDLInfo *LastDDLInfo `json:"ddl-info,omitempty"` | ||
LastFoundRows uint64 `json:"found-rows,omitempty"` | ||
FoundInPlanCache bool `json:"in-plan-cache,omitempty"` | ||
FoundInBinding bool `json:"in-binding,omitempty"` | ||
SequenceLatestValues map[int64]int64 `json:"seq-values,omitempty"` | ||
LastAffectedRows int64 `json:"affected-rows,omitempty"` | ||
LastInsertID uint64 `json:"last-insert-id,omitempty"` | ||
Warnings []stmtctx.SQLWarn `json:"warnings,omitempty"` | ||
// Define it as string to avoid cycle import. | ||
Bindings string `json:"bindings,omitempty"` | ||
} |
Oops, something went wrong.