Back to

package tidb

Latest Go to latest
Published: Apr 20, 2018 | License: Apache-2.0 | Module:



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

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

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

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

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

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

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

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

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

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

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

const (
	EngineGoLevelDBMemory = "memory://"

Engine prefix name


var (
	// SchemaOutOfDateRetryInterval is the sleeping time when we fail to try.
	SchemaOutOfDateRetryInterval = int64(500 * time.Millisecond)
	// SchemaOutOfDateRetryTimes is upper bound of retry times when the schema is out of date.
	SchemaOutOfDateRetryTimes = int32(10)
var SchemaChangedWithoutRetry bool

SchemaChangedWithoutRetry is used for testing.

func BootstrapSession

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

BootstrapSession runs the first time when the TiDB server start.

func Compile

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

Compile is safe for concurrent use by multiple goroutines.

func GetRows

func GetRows(rs ast.RecordSet) ([][]types.Datum, error)

GetRows gets all the rows from a RecordSet.

func IsQuery

func IsQuery(sql string) bool

IsQuery checks if a sql statement is a query statement.

func NewStore

func NewStore(path string) (kv.Storage, error)

NewStore creates a kv Storage with path.

The path must be a URL format 'engine://path?params' like the one for tidb.Open() but with the dbname cut off. Examples:


The engine should be registered before creating storage.

func Parse

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

Parse parses a query string to raw ast.StmtNode.

func RegisterLocalStore

func RegisterLocalStore(name string, driver engine.Driver) error

RegisterLocalStore registers a local kv storage with unique name and its associated engine Driver.

func RegisterStore

func RegisterStore(name string, driver kv.Driver) error

RegisterStore registers a kv storage with unique name and its associated Driver.

func SetCommitRetryLimit

func SetCommitRetryLimit(limit int)

SetCommitRetryLimit setups the maximum number of retries when trying to recover from retryable errors. Retryable errors are generally refer to temporary errors that are expected to be reinstated by retry, including network interruption, transaction conflicts, and so on.

func SetSchemaLease

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

func SetStatsLease(lease time.Duration)

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

type PreCommitHook

type PreCommitHook struct{}

PreCommitHook implements the fmt.Stringer interface.

func (PreCommitHook) String

func (h PreCommitHook) String() string

type Session

type Session interface {
	Status() uint16                              // Flag of current status, such as autocommit.
	LastInsertID() uint64                        // LastInsertID is the last inserted auto_increment ID.
	AffectedRows() uint64                        // Affected rows by latest executed stmt.
	Execute(sql string) ([]ast.RecordSet, error) // Execute a sql statement.
	String() string                              // String is used to debug.
	CommitTxn() error
	RollbackTxn() error
	// 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(stmtID uint32, param ...interface{}) (ast.RecordSet, error)
	DropPreparedStmt(stmtID uint32) error
	SetClientCapability(uint32) // Set client capability flags.
	SetCollation(coID int) error
	Auth(user *auth.UserIdentity, auth []byte, salt []byte) bool
	// Cancel the execution of current transaction.
	ShowProcess() util.ProcessInfo
	// PrePareTxnCtx is exported for test.
	// FieldList returns fields list of a table.
	FieldList(tableName string) (fields []*ast.ResultField, err error)

Session context

func CreateSession

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

CreateSession creates a new session environment.

type StmtHistory

type StmtHistory struct {
	// contains filtered or unexported fields

StmtHistory holds all histories of statements in a txn.

func GetHistory

func GetHistory(ctx context.Context) *StmtHistory

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

func (*StmtHistory) Add

func (h *StmtHistory) Add(stmtID uint32, st ast.Statement, stmtCtx *variable.StatementContext, params ...interface{})

Add appends a stmt to history list.

func (*StmtHistory) Count

func (h *StmtHistory) Count() int

Count returns the count of the history.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier