session

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2019 License: GPL-3.0 Imports: 83 Imported by: 0

Documentation

Overview

go-mysqlbinlog: a simple binlog tool to sync remote MySQL binlog. go-mysqlbinlog supports semi-sync mode like facebook mysqlbinlog. see http://yoshinorimatsunobu.blogspot.com/2014/04/semi-synchronous-replication-at-facebook.html

Index

Constants

View Source
const (
	// CreateUserTable is the SQL statement creates User table in system db.
	CreateUserTable = `` /* 1365-byte string literal not displayed */

	// CreateDBPrivTable is the SQL statement creates DB scope privilege table in system db.
	CreateDBPrivTable = `` /* 1127-byte string literal not displayed */

	// CreateTablePrivTable is the SQL statement creates table scope privilege table in system db.
	CreateTablePrivTable = `` /* 379-byte string literal not displayed */

	// CreateColumnPrivTable is the SQL statement creates column scope privilege table in system db.
	CreateColumnPrivTable = `` /* 299-byte string literal not displayed */

	// CreateGloablVariablesTable is the SQL statement creates global variable table in system db.
	// TODO: MySQL puts GLOBAL_VARIABLES table in INFORMATION_SCHEMA db.
	// INFORMATION_SCHEMA is a virtual db in TiDB. So we put this table in system db.
	// Maybe we will put it back to INFORMATION_SCHEMA.
	CreateGloablVariablesTable = `` /* 147-byte string literal not displayed */

	// CreateTiDBTable is the SQL statement creates a table in system db.
	// This table is a key-value struct contains some information used by TiDB.
	// Currently we only put bootstrapped in it which indicates if the system is already bootstrapped.
	CreateTiDBTable = `` /* 160-byte string literal not displayed */

	// CreateHelpTopic is the SQL statement creates help_topic table in system db.
	// See: https://dev.mysql.com/doc/refman/5.5/en/system-database.html#system-database-help-tables
	CreateHelpTopic = `` /* 392-byte string literal not displayed */

	// CreateStatsMetaTable stores the meta of table statistics.
	CreateStatsMetaTable = `` /* 270-byte string literal not displayed */

	// CreateStatsColsTable stores the statistics of table columns.
	CreateStatsColsTable = `` /* 521-byte string literal not displayed */

	// CreateStatsBucketsTable stores the histogram info for every table columns.
	CreateStatsBucketsTable = `` /* 349-byte string literal not displayed */

	// CreateGCDeleteRangeTable stores schemas which can be deleted by DeleteRange.
	CreateGCDeleteRangeTable = `` /* 390-byte string literal not displayed */

	// CreateGCDeleteRangeDoneTable stores schemas which are already deleted by DeleteRange.
	CreateGCDeleteRangeDoneTable = `` /* 400-byte string literal not displayed */

	// CreateStatsFeedbackTable stores the feedback info which is used to update stats.
	CreateStatsFeedbackTable = `` /* 216-byte string literal not displayed */

)
View Source
const (
	DBTypeMysql = iota
	DBTypeMariaDB
	DBTypeTiDB
)

数据库类型

View Source
const (
	StageOK byte = iota
	StageCheck
	StageExec
	StageBackup
)

审核阶段

View Source
const (
	StatusAuditOk byte = iota
	StatusExecFail
	StatusExecOK
	StatusBackupFail
	StatusBackupOK
)

审核状态

View Source
const (
	TABLE_COMMENT_MAXLEN           = 2048
	COLUMN_COMMENT_MAXLEN          = 1024
	INDEX_COMMENT_MAXLEN           = 1024
	TABLE_PARTITION_COMMENT_MAXLEN = 1024
)

Variables

View Source
var ErrorsChinese = map[ErrorCode]string{}/* 154 elements not displayed */
View Source
var ErrorsDefault = map[ErrorCode]string{}/* 159 elements not displayed */
View Source
var ErrorsMessage = map[ErrorCode]string{}
View Source
var Keywords = map[string]bool{}/* 387 elements not displayed */

Keywords 数据库关键字

View Source
var SchemaChangedWithoutRetry bool

SchemaChangedWithoutRetry is used for testing.

Functions

func BootstrapSession

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

BootstrapSession runs the first time when the TiDB server start.

func CheckAuditSetting added in v1.0.1

func CheckAuditSetting(cnf *config.Config)

CheckAuditSetting 自动校准旧的审核规则和自定义规则

func Compile

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

Compile is safe for concurrent use by multiple goroutines.

func DialPumpClientWithRetry

func DialPumpClientWithRetry(binlogSocket string, maxRetries int, dialerOpt grpc.DialOption) (*grpc.ClientConn, error)

DialPumpClientWithRetry tries to dial to binlogSocket, if any error happens, it will try to re-dial, or return this error when timeout.

func GetDataTypeBase

func GetDataTypeBase(dataType string) string

GetDataTypeBase 获取dataType中的数据类型,忽略长度

func GetDataTypeLength

func GetDataTypeLength(dataType string) []int

GetDataTypeLength 获取dataType中的数据类型长度

func GetDomain

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

GetDomain gets the associated domain for store.

func GetErrorLevel

func GetErrorLevel(code ErrorCode) uint8

func GetErrorMessage

func GetErrorMessage(ErrorCode ErrorCode) string

func GetRows4Test

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

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

func HTMLEscape

func HTMLEscape(w io.Writer, b []byte)

HTMLEscape writes to w the escaped HTML equivalent of the plain text data b.

func HTMLEscapeString

func HTMLEscapeString(s string) string

HTMLEscapeString returns the escaped HTML equivalent of the plain text data s.

func InterpolateParams

func InterpolateParams(query string, args []driver.Value) ([]byte, error)

func IsQuery

func IsQuery(sql string) bool

IsQuery checks if a sql statement is a query statement.

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

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 session.Open() but with the dbname cut off. Examples:

goleveldb://relative/path
boltdb:///absolute/path

The engine should be registered before creating storage.

func Parse

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

Parse parses a query string to raw ast.StmtNode.

func RegisterStore

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

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

func SetLanguage added in v0.5.1

func SetLanguage(langStr string)

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.

func StringStorageReq

func StringStorageReq(dataType string, charset string) int

StringStorageReq String Type Storage Requirements return bytes count

Types

type ChanData

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

ChanData 备份channal数据,用来传递备份的sql等信息

type ChanOscData

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

type ErrorCode added in v1.0.1

type ErrorCode int
const (
	ER_ERROR_FIRST ErrorCode = iota
	ER_NOT_SUPPORTED_YET
	ER_SQL_NO_SOURCE
	ER_SQL_NO_OP_TYPE
	ER_SQL_INVALID_OP_TYPE
	ER_PARSE_ERROR
	ER_SYNTAX_ERROR
	ER_REMOTE_EXE_ERROR
	ER_SHUTDOWN_COMPLETE
	ER_WITH_INSERT_FIELD
	ER_WITH_INSERT_VALUES
	ER_WRONG_VALUE_COUNT_ON_ROW
	ER_BAD_FIELD_ERROR
	ER_FIELD_SPECIFIED_TWICE
	ER_BAD_NULL_ERROR
	ER_NO_WHERE_CONDITION
	ER_NORMAL_SHUTDOWN
	ER_FORCING_CLOSE
	ER_CON_COUNT_ERROR
	ER_INVALID_COMMAND
	ER_SQL_INVALID_SOURCE
	ER_WRONG_DB_NAME
	ER_NO_DB_ERROR
	ER_WITH_LIMIT_CONDITION
	ER_WITH_ORDERBY_CONDITION
	ER_SELECT_ONLY_STAR
	ER_ORDERY_BY_RAND
	ER_ID_IS_UPER
	ER_UNKNOWN_COLLATION
	ER_INVALID_DATA_TYPE
	ER_NOT_ALLOWED_NULLABLE
	ER_DUP_FIELDNAME
	ER_WRONG_COLUMN_NAME
	ER_WRONG_AUTO_KEY
	ER_TABLE_CANT_HANDLE_AUTO_INCREMENT
	ER_FOREIGN_KEY
	ER_TOO_MANY_KEY_PARTS
	ER_TOO_LONG_IDENT
	ER_UDPATE_TOO_MUCH_ROWS
	ER_INSERT_TOO_MUCH_ROWS
	ER_CHANGE_TOO_MUCH_ROWS
	ER_WRONG_NAME_FOR_INDEX
	ER_TOO_MANY_KEYS
	ER_NOT_SUPPORTED_KEY_TYPE
	ER_WRONG_SUB_KEY
	ER_WRONG_KEY_COLUMN
	ER_TOO_LONG_KEY
	ER_MULTIPLE_PRI_KEY
	ER_DUP_KEYNAME
	ER_TOO_LONG_INDEX_COMMENT
	ER_DUP_INDEX
	ER_TEMP_TABLE_TMP_PREFIX
	ER_TABLE_CHARSET_MUST_UTF8
	ER_TABLE_CHARSET_MUST_NULL
	ER_TABLE_MUST_HAVE_COMMENT
	ER_COLUMN_HAVE_NO_COMMENT
	ER_TABLE_MUST_HAVE_PK
	ER_PARTITION_NOT_ALLOWED
	ER_USE_ENUM
	ER_USE_TEXT_OR_BLOB
	ER_COLUMN_EXISTED
	ER_COLUMN_NOT_EXISTED
	ER_CANT_DROP_FIELD_OR_KEY
	ER_INVALID_DEFAULT
	ER_USERNAME
	ER_HOSTNAME
	ER_NOT_VALID_PASSWORD
	ER_WRONG_STRING_LENGTH
	ER_BLOB_USED_AS_KEY
	ER_TOO_LONG_BAKDB_NAME
	ER_INVALID_BACKUP_HOST_INFO
	ER_BINLOG_CORRUPTED
	ER_NET_READ_ERROR
	ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
	ER_SLAVE_RELAY_LOG_WRITE_FAILURE
	ER_INCORRECT_GLOBAL_LOCAL_VAR
	ER_START_AS_BEGIN
	ER_OUTOFMEMORY
	ER_HAVE_BEGIN
	ER_NET_READ_INTERRUPTED
	ER_BINLOG_FORMAT_STATEMENT
	ER_ERROR_EXIST_BEFORE
	ER_UNKNOWN_SYSTEM_VARIABLE
	ER_UNKNOWN_CHARACTER_SET
	ER_END_WITH_COMMIT
	ER_DB_NOT_EXISTED_ERROR
	ER_TABLE_EXISTS_ERROR
	ER_INDEX_NAME_IDX_PREFIX
	ER_INDEX_NAME_UNIQ_PREFIX
	ER_AUTOINC_UNSIGNED
	ER_VARCHAR_TO_TEXT_LEN
	ER_CHAR_TO_VARCHAR_LEN
	ER_KEY_COLUMN_DOES_NOT_EXITS
	ER_INC_INIT_ERR
	ER_WRONG_ARGUMENTS
	ER_SET_DATA_TYPE_INT_BIGINT
	ER_TIMESTAMP_DEFAULT
	ER_CHARSET_ON_COLUMN
	ER_AUTO_INCR_ID_WARNING
	ER_ALTER_TABLE_ONCE
	ER_BLOB_CANT_HAVE_DEFAULT
	ER_END_WITH_SEMICOLON
	ER_NON_UNIQ_ERROR
	ER_TABLE_NOT_EXISTED_ERROR
	ER_UNKNOWN_TABLE
	ER_INVALID_GROUP_FUNC_USE
	ER_INDEX_USE_ALTER_TABLE
	ER_WITH_DEFAULT_ADD_COLUMN
	ER_TRUNCATED_WRONG_VALUE
	ER_TEXT_NOT_NULLABLE_ERROR
	ER_WRONG_VALUE_FOR_VAR
	ER_TOO_MUCH_AUTO_TIMESTAMP_COLS
	ER_INVALID_ON_UPDATE
	ER_DDL_DML_COEXIST
	ER_SLAVE_CORRUPT_EVENT
	ER_COLLATION_CHARSET_MISMATCH
	ER_NOT_SUPPORTED_ALTER_OPTION
	ER_CONFLICTING_DECLARATIONS
	ER_IDENT_USE_KEYWORD
	ER_VIEW_SELECT_CLAUSE
	ER_OSC_KILL_FAILED
	ER_NET_PACKETS_OUT_OF_ORDER
	ER_NOT_SUPPORTED_ITEM_TYPE
	ER_INVALID_IDENT
	ER_INCEPTION_EMPTY_QUERY
	ER_PK_COLS_NOT_INT
	ER_PK_TOO_MANY_PARTS
	ER_REMOVED_SPACES
	ER_CHANGE_COLUMN_TYPE
	ER_CANT_DROP_TABLE
	ER_CANT_DROP_DATABASE
	ER_WRONG_TABLE_NAME
	ER_CANT_SET_CHARSET
	ER_CANT_SET_COLLATION
	ER_CANT_SET_ENGINE
	ER_MUST_AT_LEAST_ONE_COLUMN
	ER_MUST_HAVE_COLUMNS
	ER_PRIMARY_CANT_HAVE_NULL
	ErrCantRemoveAllFields
	ErrNotFoundTableInfo
	ErrNotFoundThreadId
	ErrNotFoundMasterStatus
	ErrNonUniqTable
	ErrWrongUsage
	ErrDataTooLong
	ErrCharsetNotSupport
	ErrCollationNotSupport
	ErrTableCollationNotSupport
	ErrJsonTypeSupport
	ErrEngineNotSupport
	ErrMixOfGroupFuncAndFields
	ErrFieldNotInGroupBy
	ErCantChangeColumnPosition
	ErCantChangeColumn
	ER_DATETIME_DEFAULT
	ER_TOO_MUCH_AUTO_DATETIME_COLS
	ErrFloatDoubleToDecimal
	ErrIdentifierUpper
	ER_ERROR_LAST
)

func (ErrorCode) String added in v1.0.1

func (e ErrorCode) String() string

type ExplainInfo

type ExplainInfo struct {
	gorm.Model

	SelectType   string  `gorm:"Column:select_type"`
	Table        string  `gorm:"Column:table"`
	Partitions   string  `gorm:"Column:partitions"`
	Type         string  `gorm:"Column:type"`
	PossibleKeys string  `gorm:"Column:possible_keys"`
	Key          string  `gorm:"Column:key"`
	KeyLen       string  `gorm:"Column:key_len"`
	Ref          string  `gorm:"Column:ref"`
	Rows         int     `gorm:"Column:rows"`
	Filtered     float32 `gorm:"Column:filtered"`
	Extra        string  `gorm:"Column:Extra"`
}

ExplainInfo 执行计划信息

type FieldInfo

type FieldInfo struct {
	gorm.Model

	Field      string  `gorm:"Column:Field"`
	Type       string  `gorm:"Column:Type"`
	Collation  string  `gorm:"Column:Collation"`
	Null       string  `gorm:"Column:Null"`
	Key        string  `gorm:"Column:Key"`
	Default    *string `gorm:"Column:Default"`
	Extra      string  `gorm:"Column:Extra"`
	Privileges string  `gorm:"Column:Privileges"`
	Comment    string  `gorm:"Column:Comment"`

	IsDeleted bool `gorm:"-"`
	IsNew     bool `gorm:"-"`

	Tp *types.FieldType `gorm:"-"`
}

FieldInfo 字段信息

func (*FieldInfo) GetDataBytes

func (col *FieldInfo) GetDataBytes(dbVersion int) int

GetDataBytes 计算数据类型字节数 https://dev.mysql.com/doc/refman/8.0/en/storage-requirements.html return -1 表示该列无法计算数据大小

func (*FieldInfo) IsUnsigned added in v0.8.2

func (f *FieldInfo) IsUnsigned() bool

IsUnsigned 是否无符号列

type IndexInfo

type IndexInfo struct {
	gorm.Model

	Table      string `gorm:"Column:Table"`
	NonUnique  int    `gorm:"Column:Non_unique"`
	IndexName  string `gorm:"Column:Key_name"`
	Seq        int    `gorm:"Column:Seq_in_index"`
	ColumnName string `gorm:"Column:Column_name"`
	IndexType  string `gorm:"Column:Index_type"`

	IsDeleted bool `gorm:"-"`
}

IndexInfo 索引信息

type LevelSets added in v1.0.1

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

func NewLevelSets added in v1.0.1

func NewLevelSets(count int) *LevelSets

func (*LevelSets) Append added in v1.0.1

func (s *LevelSets) Append(name string, value int64, desc string)

func (*LevelSets) Rows added in v1.0.1

func (s *LevelSets) Rows() []sqlexec.RecordSet

type MasterStatus

type MasterStatus struct {
	gorm.Model
	File            string `gorm:"Column:File"`
	Position        int    `gorm:"Column:Position"`
	BinlogDoDB      string `gorm:"Column:Binlog_Do_DB"`
	BinlogIgnoreDB  string `gorm:"Column:Binlog_Ignore_DB"`
	ExecutedGtidSet string `gorm:"Column:Executed_Gtid_Set"`
}

MasterStatus 主库状态信息,包括当前日志文件,位置等

type MyRecordSets

type MyRecordSets struct {
	MaxLevel uint8

	SeqNo int
	// contains filtered or unexported fields
}

func NewRecordSets

func NewRecordSets() *MyRecordSets

func (*MyRecordSets) All

func (s *MyRecordSets) All() []*Record

func (*MyRecordSets) Append

func (s *MyRecordSets) Append(r *Record)

func (*MyRecordSets) Next

func (s *MyRecordSets) Next() *Record

func (*MyRecordSets) Rows

func (s *MyRecordSets) Rows() []sqlexec.RecordSet

type PrintSets added in v0.7.1

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

func NewPrintSets added in v0.7.1

func NewPrintSets() *PrintSets

func (*PrintSets) Append added in v0.7.1

func (s *PrintSets) Append(errLevel int64, sql, tree, errmsg string)

func (*PrintSets) Rows added in v0.7.1

func (s *PrintSets) Rows() []sqlexec.RecordSet

type ProcessListSets

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

func NewOscProcessListSets

func NewOscProcessListSets(count int, hideCommand bool) *ProcessListSets

func NewProcessListSets

func NewProcessListSets(count int) *ProcessListSets

func (*ProcessListSets) Rows

func (s *ProcessListSets) Rows() []sqlexec.RecordSet

type Record

type Record struct {
	// 阶段   RERUN EXECUTED CHECKED
	Stage byte
	// 阶段说明 Execute Successfully / 审核完成 / 失败...
	// Audit completed
	// Execute failed
	// Execute Successfully
	// Execute Successfully,Backup successfully
	// Execute Successfully,Backup failed
	StageStatus byte

	// 审核级别,0为成功,1为警告,2为错误
	ErrLevel uint8
	// 错误/警告信息
	ErrorMessage string

	Sql string

	// 受影响行
	AffectedRows int

	// 备份库的库名
	BackupDBName string

	// 执行用时
	ExecTime string

	// 备份用时
	BackupCostTime string

	// sql的hash值,osc使用
	Sqlsha1 string

	Buf *bytes.Buffer

	Type ast.StmtNode

	// 备份相关
	ExecTimestamp int64
	StartFile     string
	StartPosition int
	EndFile       string
	EndPosition   int
	ThreadId      uint32
	SeqNo         int

	DBName    string
	TableName string
	TableInfo *TableInfo
	// ddl回滚
	DDLRollback string
	OPID        string

	ExecComplete bool
	// contains filtered or unexported fields
}

func (*Record) AppendErrorMessage

func (r *Record) AppendErrorMessage(msg string)

func (*Record) AppendErrorNo

func (r *Record) AppendErrorNo(number ErrorCode, values ...interface{})

func (*Record) AppendWarning added in v0.7.1

func (r *Record) AppendWarning(number ErrorCode, values ...interface{})

AppendWarning 添加警告. 错误级别指定为警告

type Rewrite added in v1.0.1

type Rewrite struct {
	SQL    string
	NewSQL string
	Stmt   sqlparser.Statement
}

Rewrite 用于重写SQL

func NewRewrite added in v1.0.1

func NewRewrite(sql string) (*Rewrite, error)

NewRewrite 返回一个*Rewrite对象,如果SQL无法被正常解析,将错误输出到日志中,返回一个nil

func (*Rewrite) Rewrite added in v1.0.1

func (rw *Rewrite) Rewrite() (*Rewrite, error)

Rewrite 入口函数

func (*Rewrite) RewriteDML2Select added in v1.0.1

func (rw *Rewrite) RewriteDML2Select() (*Rewrite, error)

RewriteDML2Select dml2select: DML 转成 SELECT,兼容低版本的 EXPLAIN

type SQLError

type SQLError struct {
	Code    ErrorCode
	Message string
}

SQLError records an error information, from executing SQL.

func NewErr

func NewErr(errCode ErrorCode, args ...interface{}) *SQLError

NewErr generates a SQL error, with an error code and default format specifier defined in MySQLErrName.

func NewErrf

func NewErrf(format string, args ...interface{}) *SQLError

NewErrf creates a SQL error, with an error code and a format specifier.

func (*SQLError) Error

func (e *SQLError) Error() string

Error prints errors, with a formatted string.

type Session

type Session interface {
	sessionctx.Context
	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(context.Context, string) ([]sqlexec.RecordSet, error)    // Execute a sql statement.
	ExecuteInc(context.Context, string) ([]sqlexec.RecordSet, error) // Execute a sql statement.
	String() string                                                  // String is used to debug.
	CommitTxn(context.Context) error
	RollbackTxn(context.Context) 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(ctx context.Context, stmtID uint32, param ...interface{}) (sqlexec.RecordSet, error)
	DropPreparedStmt(stmtID uint32) error
	SetClientCapability(uint32) // Set client capability flags.
	SetConnectionID(uint64)
	SetCommandValue(byte)
	SetProcessInfo(string, time.Time, byte)
	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

func CreateSession

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

CreateSession creates a new session environment.

func CreateSession4Test

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

CreateSession4Test creates a new session environment for test.

type SplitSets added in v1.0.1

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

func NewSplitSets added in v1.0.1

func NewSplitSets() *SplitSets

func (*SplitSets) Append added in v1.0.1

func (s *SplitSets) Append(sql string, errmsg string)

func (*SplitSets) CurrentId added in v1.0.1

func (s *SplitSets) CurrentId() int64

CurrentId 当前ID

func (*SplitSets) Increment added in v1.0.1

func (s *SplitSets) Increment()

id累加

func (*SplitSets) Rows added in v1.0.1

func (s *SplitSets) Rows() []sqlexec.RecordSet

type StmtHistory

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

StmtHistory holds all histories of statements in a txn.

func GetHistory

func GetHistory(ctx sessionctx.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 *stmtctx.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.

type TableInfo

type TableInfo struct {
	Schema string
	Name   string
	// 表别名,仅用于update,delete多表
	AsName string
	Fields []FieldInfo

	// 索引
	Indexes []*IndexInfo

	// 是否已删除
	IsDeleted bool
	// 备份库是否已创建
	IsCreated bool

	// 表是否为新增
	IsNew bool
	// 列是否为新增
	IsNewColumns bool

	AlterCount int

	// 是否已清除已删除的列[解析binlog时会自动清除已删除的列]
	IsClear bool

	// 表大小.单位MB
	TableSize uint
	// contains filtered or unexported fields
}

TableInfo 表结构. 表结构实现了快照功能,在表结构变更前,会复制快照,在快照上做变更 在解析binlog时,基于执行时的快照做binlog解析,以实现删除列时的binlog解析

type TxnState

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 befort StartTS() is really need.

func (*TxnState) Commit

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

Commit overrides the Transaction interface.

func (*TxnState) Delete

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

Delete overrides the Transaction interface.

func (*TxnState) Get

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

Get overrides the Transaction interface.

func (*TxnState) Rollback

func (st *TxnState) Rollback() error

Rollback overrides the Transaction interface.

func (*TxnState) Seek

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

Seek overrides the Transaction interface.

func (*TxnState) SeekReverse

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

SeekReverse overrides the Transaction interface.

func (*TxnState) Set

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

Set overrides the Transaction interface.

func (*TxnState) String

func (st *TxnState) String() string

func (*TxnState) Valid

func (st *TxnState) Valid() bool

Valid overrides Transaction interface.

type VariableSets

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

func NewVariableSets

func NewVariableSets(count int) *VariableSets

func (*VariableSets) Append

func (s *VariableSets) Append(name string, value string)

func (*VariableSets) Rows

func (s *VariableSets) Rows() []sqlexec.RecordSet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL