tidb: github.com/pingcap/tidb/session Index | Files

package session

import "github.com/pingcap/tidb/session"

Index

Package Files

bootstrap.go session.go tidb.go txn.go

Constants

const (
    CreateUserTable = "" /* 1587 byte string literal not displayed */

    CreateDBPrivTable = "" /* 1129 byte string literal not displayed */

    CreateTablePrivTable = "" /* 429 byte string literal not displayed */

    CreateColumnPrivTable = "" /* 301 byte string literal not displayed */

    CreateGloablVariablesTable = "" /* 149 byte string literal not displayed */

    CreateTiDBTable = "" /* 162 byte string literal not displayed */

    CreateHelpTopic = "" /* 394 byte string literal not displayed */

    CreateStatsMetaTable = "" /* 272 byte string literal not displayed */

    CreateStatsColsTable = "" /* 602 byte string literal not displayed */

    CreateStatsBucketsTable = "" /* 351 byte string literal not displayed */

    CreateGCDeleteRangeTable = "" /* 392 byte string literal not displayed */

    CreateGCDeleteRangeDoneTable = "" /* 402 byte string literal not displayed */

    CreateStatsFeedbackTable = "" /* 218 byte string literal not displayed */

    CreateBindInfoTable = "" /* 572 byte string literal not displayed */

    CreateRoleEdgesTable = "" /* 434 byte string literal not displayed */

    CreateDefaultRolesTable = "" /* 358 byte string literal not displayed */

    CreateStatsTopNTable = "" /* 244 byte string literal not displayed */

    CreateExprPushdownBlacklist = `CREATE TABLE IF NOT EXISTS mysql.expr_pushdown_blacklist (
		name char(100) NOT NULL
	);`

    CreateOptRuleBlacklist = `CREATE TABLE IF NOT EXISTS mysql.opt_rule_blacklist (
		name char(100) NOT NULL
	);`
)

Variables

var (
    ErrForUpdateCantRetry = terror.ClassSession.New(codeForUpdateCantRetry,
        mysql.MySQLErrName[mysql.ErrForUpdateCantRetry])
)

Session errors.

var SchemaChangedWithoutRetry bool

SchemaChangedWithoutRetry is used for testing.

func BootstrapSession Uses

func BootstrapSession(store kv.Storage) (*domain.Domain, error)

BootstrapSession runs the first time when the TiDB server start.

func Compile Uses

func Compile(ctx context.Context, sctx sessionctx.Context, stmtNode ast.StmtNode) (sqlexec.Statement, error)

Compile is safe for concurrent use by multiple goroutines.

func DisableStats4Test Uses

func DisableStats4Test()

DisableStats4Test disables the stats for tests.

func GetDomain Uses

func GetDomain(store kv.Storage) (*domain.Domain, error)

GetDomain gets the associated domain for store.

func GetRows4Test Uses

func GetRows4Test(ctx context.Context, sctx sessionctx.Context, rs sqlexec.RecordSet) ([]chunk.Row, error)

GetRows4Test gets all the rows from a RecordSet, only used for test.

func Parse Uses

func Parse(ctx sessionctx.Context, src string) ([]ast.StmtNode, error)

Parse parses a query string to raw ast.StmtNode.

func ResultSetToStringSlice Uses

func ResultSetToStringSlice(ctx context.Context, s Session, rs sqlexec.RecordSet) ([][]string, error)

ResultSetToStringSlice changes the RecordSet to [][]string.

func SetSchemaLease Uses

func SetSchemaLease(lease time.Duration)

SetSchemaLease changes the default schema lease time for DDL. This function is very dangerous, don't use it if you really know what you do. SetSchemaLease only affects not local storage after bootstrapped.

func SetStatsLease Uses

func SetStatsLease(lease time.Duration)

SetStatsLease changes the default stats lease time for loading stats info.

type Session Uses

type Session interface {
    sessionctx.Context
    Status() uint16                                               // Flag of current status, such as autocommit.
    LastInsertID() uint64                                         // LastInsertID is the last inserted auto_increment ID.
    LastMessage() string                                          // LastMessage is the info message that may be generated by last command
    AffectedRows() uint64                                         // Affected rows by latest executed stmt.
    Execute(context.Context, string) ([]sqlexec.RecordSet, error) // Execute a sql statement.
    String() string                                               // String is used to debug.
    CommitTxn(context.Context) error
    RollbackTxn(context.Context)
    // PrepareStmt executes prepare statement in binary protocol.
    PrepareStmt(sql string) (stmtID uint32, paramCount int, fields []*ast.ResultField, err error)
    // ExecutePreparedStmt executes a prepared statement.
    ExecutePreparedStmt(ctx context.Context, stmtID uint32, param []types.Datum) (sqlexec.RecordSet, error)
    DropPreparedStmt(stmtID uint32) error
    SetClientCapability(uint32) // Set client capability flags.
    SetConnectionID(uint64)
    SetCommandValue(byte)
    SetProcessInfo(string, time.Time, byte, uint64)
    SetTLSState(*tls.ConnectionState)
    SetCollation(coID int) error
    SetSessionManager(util.SessionManager)
    Close()
    Auth(user *auth.UserIdentity, auth []byte, salt []byte) bool
    ShowProcess() *util.ProcessInfo
    // PrePareTxnCtx is exported for test.
    PrepareTxnCtx(context.Context)
    // FieldList returns fields list of a table.
    FieldList(tableName string) (fields []*ast.ResultField, err error)
}

Session context, it is consistent with the lifecycle of a client connection.

func CreateSession Uses

func CreateSession(store kv.Storage) (Session, error)

CreateSession creates a new session environment.

func CreateSession4Test Uses

func CreateSession4Test(store kv.Storage) (Session, error)

CreateSession4Test creates a new session environment for test.

type StmtHistory Uses

type StmtHistory struct {
    // contains filtered or unexported fields
}

StmtHistory holds all histories of statements in a txn.

func GetHistory Uses

func GetHistory(ctx sessionctx.Context) *StmtHistory

GetHistory get all stmtHistory in current txn. Exported only for test.

func (*StmtHistory) Add Uses

func (h *StmtHistory) Add(st sqlexec.Statement, stmtCtx *stmtctx.StatementContext)

Add appends a stmt to history list.

func (*StmtHistory) Count Uses

func (h *StmtHistory) Count() int

Count returns the count of the history.

type TxnState Uses

type TxnState struct {
    // States of a TxnState should be one of the followings:
    // Invalid: kv.Transaction == nil && txnFuture == nil
    // Pending: kv.Transaction == nil && txnFuture != nil
    // Valid:	kv.Transaction != nil && txnFuture == nil
    kv.Transaction
    // contains filtered or unexported fields
}

TxnState wraps kv.Transaction to provide a new kv.Transaction. 1. It holds all statement related modification in the buffer before flush to the txn, so if execute statement meets error, the txn won't be made dirty. 2. It's a lazy transaction, that means it's a txnFuture before StartTS() is really need.

func (*TxnState) BatchGet Uses

func (st *TxnState) BatchGet(ctx context.Context, keys []kv.Key) (map[string][]byte, error)

BatchGet overrides the Transaction interface.

func (*TxnState) Commit Uses

func (st *TxnState) Commit(ctx context.Context) error

Commit overrides the Transaction interface.

func (*TxnState) Delete Uses

func (st *TxnState) Delete(k kv.Key) error

Delete overrides the Transaction interface.

func (*TxnState) Get Uses

func (st *TxnState) Get(ctx context.Context, k kv.Key) ([]byte, error)

Get overrides the Transaction interface.

func (*TxnState) GoString Uses

func (st *TxnState) GoString() string

GoString implements the "%#v" format for fmt.Printf.

func (*TxnState) Iter Uses

func (st *TxnState) Iter(k kv.Key, upperBound kv.Key) (kv.Iterator, error)

Iter overrides the Transaction interface.

func (*TxnState) IterReverse Uses

func (st *TxnState) IterReverse(k kv.Key) (kv.Iterator, error)

IterReverse overrides the Transaction interface.

func (*TxnState) KeysNeedToLock Uses

func (st *TxnState) KeysNeedToLock() ([]kv.Key, error)

KeysNeedToLock returns the keys need to be locked.

func (*TxnState) Rollback Uses

func (st *TxnState) Rollback() error

Rollback overrides the Transaction interface.

func (*TxnState) Set Uses

func (st *TxnState) Set(k kv.Key, v []byte) error

Set overrides the Transaction interface.

func (*TxnState) String Uses

func (st *TxnState) String() string

func (*TxnState) Valid Uses

func (st *TxnState) Valid() bool

Valid implements the kv.Transaction interface.

Package session imports 58 packages (graph) and is imported by 60 packages. Updated 2019-11-20. Refresh now. Tools for package owners.