session

package
v0.0.0-...-d8288c5 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: GPL-3.0 Imports: 118 Imported by: 0

Documentation

Index

Constants

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

	// CreateGlobalPrivTable is the SQL statement creates Global scope privilege table in system db.
	CreateGlobalPrivTable = "CREATE TABLE IF NOT EXISTS mysql.global_priv (" +
		"Host CHAR(255) NOT NULL DEFAULT ''," +
		"User CHAR(80) NOT NULL DEFAULT ''," +
		"Priv LONGTEXT NOT NULL DEFAULT ''," +
		"PRIMARY KEY (Host, User)" +
		")"
	// CreateDBPrivTable is the SQL statement creates DB scope privilege table in system db.
	CreateDBPrivTable = `` /* 1163-byte string literal not displayed */

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

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

	// CreateGlobalVariablesTable 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.
	CreateGlobalVariablesTable = `` /* 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 = `` /* 164-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 = `` /* 418-byte string literal not displayed */

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

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

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

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

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

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

	// CreateBindInfoTable stores the sql bind info which is used to update globalBindCache.
	CreateBindInfoTable = `` /* 602-byte string literal not displayed */

	// CreateRoleEdgesTable stores the role and user relationship information.
	CreateRoleEdgesTable = `` /* 445-byte string literal not displayed */

	// CreateDefaultRolesTable stores the active roles for a user.
	CreateDefaultRolesTable = `` /* 366-byte string literal not displayed */

	// CreateStatsTopNTable stores topn data of a cmsketch with top n.
	CreateStatsTopNTable = `` /* 249-byte string literal not displayed */

	// CreateStatsFMSketchTable stores FMSketch data of a column histogram.
	CreateStatsFMSketchTable = `` /* 213-byte string literal not displayed */

	// CreateExprPushdownBlacklist stores the expressions which are not allowed to be pushed down.
	CreateExprPushdownBlacklist = `` /* 177-byte string literal not displayed */

	// CreateOptRuleBlacklist stores the list of disabled optimizing operations.
	CreateOptRuleBlacklist = `CREATE TABLE IF NOT EXISTS mysql.opt_rule_blacklist (
		name 	CHAR(100) NOT NULL
	);`

	// CreateStatsExtended stores the registered extended statistics.
	CreateStatsExtended = `` /* 376-byte string literal not displayed */

	// CreateSchemaIndexUsageTable stores the index usage information.
	CreateSchemaIndexUsageTable = `` /* 217-byte string literal not displayed */

	// CreateGlobalGrantsTable stores dynamic privs
	CreateGlobalGrantsTable = `` /* 251-byte string literal not displayed */

	// CreateCapturePlanBaselinesBlacklist stores the baseline capture filter rules.
	CreateCapturePlanBaselinesBlacklist = `` /* 291-byte string literal not displayed */

	// CreateColumnStatsUsageTable stores the column stats usage information.
	CreateColumnStatsUsageTable = `` /* 224-byte string literal not displayed */

)
View Source
const (
	DBTypeMysql = iota
	DBTypeMariaDB
	DBTypeTiDB
	DBTypeOceanBase
	DBTypeDrds
	DBPostgreSQL
)

数据库类型

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

审核阶段

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

审核状态

View Source
const (
	CreateTablePgAggregate = `` /* 940-byte string literal not displayed */

	CreateTablePgAm = `` /* 161-byte string literal not displayed */

	CreateTablePgAmop = `` /* 435-byte string literal not displayed */

	CreateTablePgAmproc = `` /* 300-byte string literal not displayed */

	CreateTablePgAttrdef = `` /* 193-byte string literal not displayed */

	CreateTablePgAttribute = `` /* 927-byte string literal not displayed */

	CreateTablePgAuthMembers = `` /* 220-byte string literal not displayed */

	CreateTablePgAuthID = `` /* 473-byte string literal not displayed */

	CreateTablePgCast = `` /* 289-byte string literal not displayed */

	CreateTablePgClass = `` /* 1324-byte string literal not displayed */

	CreateTablePgCollation = `` /* 432-byte string literal not displayed */

	CreateTablePgConstraint = `` /* 962-byte string literal not displayed */

	CreateTablePgConversion = `` /* 353-byte string literal not displayed */

	CreateTablePgDatabase = `` /* 606-byte string literal not displayed */

	CreateTablePgDbRoleSetting = `` /* 168-byte string literal not displayed */

	CreateTablePgDefaultACL = `` /* 263-byte string literal not displayed */

	CreateTablePgDepend = `` /* 326-byte string literal not displayed */

	CreateTablePgDescription = `` /* 206-byte string literal not displayed */

	CreateTablePgEnum = `` /* 201-byte string literal not displayed */

	CreateTablePgEventTrigger = `` /* 304-byte string literal not displayed */

	CreateTablePgExtension = `` /* 347-byte string literal not displayed */

	CreateTablePgForeignDataWrapper = `` /* 320-byte string literal not displayed */

	CreateTablePgForeignServer = `` /* 301-byte string literal not displayed */

	CreateTablePgForeignTable = `` /* 163-byte string literal not displayed */

	CreateTablePgIndex = `` /* 763-byte string literal not displayed */

	CreateTablePgInherits = `` /* 175-byte string literal not displayed */

	CreateTablePgInitPrivs = `` /* 242-byte string literal not displayed */

	CreateTablePgLanguage = `` /* 397-byte string literal not displayed */

	CreateTablePgLargeObject = `` /* 153-byte string literal not displayed */

	CreateTablePgLargeObjectMetadata = `` /* 171-byte string literal not displayed */

	CreateTablePgNamespace = `` /* 194-byte string literal not displayed */

	CreateTablePgOpclass = `` /* 432-byte string literal not displayed */

	CreateTablePgOperator = `` /* 619-byte string literal not displayed */

	CreateTablePgOpFamily = `` /* 261-byte string literal not displayed */

	CreateTablePgPartitionedTable = `` /* 347-byte string literal not displayed */

	CreateTablePgPolicy = `` /* 319-byte string literal not displayed */

	CreateTablePgProc = `` /* 1029-byte string literal not displayed */

	CreateTablePgPublication = `` /* 387-byte string literal not displayed */

	CreateTablePgPublicationRel = `` /* 183-byte string literal not displayed */

	CreateTablePgRange = `` /* 293-byte string literal not displayed */

	CreateTablePgReplicationOrigin = `` /* 130-byte string literal not displayed */

	CreateTablePgRewrite = `` /* 323-byte string literal not displayed */

	CreateTablePgSeclabel = `` /* 225-byte string literal not displayed */

	CreateTablePgSequence = `` /* 323-byte string literal not displayed */

	CreateTablePgShdepend = `` /* 330-byte string literal not displayed */

	CreateTablePgShdescription = `` /* 173-byte string literal not displayed */

	CreateTablePgShseclabel = `` /* 192-byte string literal not displayed */

	CreateTablePgStatistic = `` /* 1109-byte string literal not displayed */

	CreateTablePgStatisticExt = `` /* 369-byte string literal not displayed */

	CreateTablePgStatisticExtData = `` /* 193-byte string literal not displayed */

	CreateTablePgSubscription = `` /* 379-byte string literal not displayed */

	CreateTablePgSubscriptionRel = `` /* 204-byte string literal not displayed */

	CreateTablePgTablespace = `` /* 217-byte string literal not displayed */

	CreateTablePgTransform = `` /* 235-byte string literal not displayed */

	CreateTablePgTrigger = `` /* 742-byte string literal not displayed */

	CreateTablePgTsConfig = `` /* 253-byte string literal not displayed */

	CreateTablePgTsConfigMap = `` /* 215-byte string literal not displayed */

	CreateTablePgTsDict = `` /* 282-byte string literal not displayed */

	CreateTablePgTsParser = `` /* 316-byte string literal not displayed */

	CreateTablePgTsTemplate = `` /* 235-byte string literal not displayed */

	CreateTablePgType = `` /* 1117-byte string literal not displayed */

	CreateTablePgUserMapping = `` /* 200-byte string literal not displayed */

	CreateTablePgAllSettings = `` /* 350-byte string literal not displayed */

	CreateTablePgStatActivity = `` /* 592-byte string literal not displayed */

)

PG SYSTEM TABLE SQL

View Source
const (
	CreateViewPgRoles = `` /* 500-byte string literal not displayed */

	CreateViewPgShadow = `` /* 486-byte string literal not displayed */

	CreateViewPgGroup = `` /* 234-byte string literal not displayed */

	CreateViewPgUser = `` /* 258-byte string literal not displayed */

	CreateViewPgSettings = `CREATE OR REPLACE DEFINER = root VIEW pg_settings AS
SELECT * FROM pg_all_settings;`
)

PG SYSTEM VIEW SQL

View Source
const (
	DataForTablePgAggregate = `` /* 632-byte string literal not displayed */

	DataForTablePgAuthMembers = `INSERT INTO postgres.pg_auth_members VALUES
(3374,3373,10,0),
(3375,3373,10,0),
(3377,3373,10,0);`

	DataForTablePgDatabase = `` /* 457-byte string literal not displayed */

	DataForTablePgClass = `` /* 65479-byte string literal not displayed */

	DataForTablePgType = `` /* 358-byte string literal not displayed */

	DataForTablePgTablespace = `INSERT INTO postgres.pg_tablespace VALUES
(1663,'pg_default',10,NULL,NULL),
(1664,'pg_global',10,NULL,NULL);`

	DataForTablePgNamespace = `` /* 251-byte string literal not displayed */

	DataForTablePgAllSettings = `` /* 79832-byte string literal not displayed */

	DataForTablePgProc = `` /* 528429-byte string literal not displayed */

)

DATA FOR PG SYSTEM TABLE nolint

View Source
const (
	AmendNone int = iota

	// For add index.
	AmendNeedAddDelete
	AmendNeedAddDeleteAndInsert
	AmendNeedAddInsert
)

Amend operation types.

View Source
const (
	TABLE_COMMENT_MAXLEN           = 2048
	COLUMN_COMMENT_MAXLEN          = 1024
	INDEX_COMMENT_MAXLEN           = 1024
	TABLE_PARTITION_COMMENT_MAXLEN = 1024
	TABLE_SHARD_ROW_ID_BITS_MAXLEN = 15
)
View Source
const (
	// ErrExprInSelect  is in select fields for the error of ErrFieldNotInGroupBy
	ErrExprInSelect = "SELECT list"
	// ErrExprInOrderBy  is in order by items for the error of ErrFieldNotInGroupBy
	ErrExprInOrderBy = "ORDER BY"
)

Variables

View Source
var (
	StageList  = [4]string{"RERUN", "CHECKED", "EXECUTED", "BACKUP"}
	StatusList = [5]string{"Audit Completed", "Execute failed", "Execute Successfully",
		"Execute Successfully\nBackup failed", "Execute Successfully\nBackup Successfully"}
)
View Source
var (
	ErrWrongValueForVar    = dbterror.ClassVariable.NewStd(mysql.ErrWrongValueForVar)
	ErrTruncatedWrongValue = dbterror.ClassVariable.NewStd(mysql.ErrTruncatedWrongValue)
	ErrWrongTypeForVar     = dbterror.ClassVariable.NewStd(mysql.ErrWrongTypeForVar)
)
View Source
var (
	// All the exported errors are defined here:
	ErrIncorrectParameterCount = dbterror.ClassVariable.NewStd(mysql.ErrWrongParamcountToNativeFct)
	ErrDivisionByZero          = dbterror.ClassVariable.NewStd(mysql.ErrDivisionByZero)
	ErrRegexp                  = dbterror.ClassVariable.NewStd(mysql.ErrRegexp)
	ErrOperandColumns          = dbterror.ClassVariable.NewStd(mysql.ErrOperandColumns)
	ErrCutValueGroupConcat     = dbterror.ClassVariable.NewStd(mysql.ErrCutValueGroupConcat)
)

ConstOpAddIndex is the possible ddl state changes, and related amend action types.

View Source
var (
	ErrForUpdateCantRetry = dbterror.ClassSession.NewStd(errno.ErrForUpdateCantRetry)
)

Session errors.

View Source
var ErrorsChinese = map[ErrorCode]string{}/* 204 elements not displayed */
View Source
var ErrorsDefault = map[ErrorCode]string{}/* 212 elements not displayed */
View Source
var IntegerOrderedMaps = map[string]int{
	"bit":       1,
	"tinyint":   2,
	"smallint":  3,
	"mediumint": 4,
	"int":       5,
	"bigint":    6,
}

int类型map(用以数值列类型变更审核)

View Source
var IntegerOrderedMaps2 = map[byte]int{
	mysql.TypeBit:      1,
	mysql.TypeTiny:     2,
	mysql.TypeShort:    3,
	mysql.TypeInt24:    4,
	mysql.TypeLong:     5,
	mysql.TypeLonglong: 6,
}

int类型map(用以数值列类型变更审核)

View Source
var Keywords = map[string]bool{}/* 767 elements not displayed */

Keywords 数据库关键字

View Source
var SchemaChangedWithoutRetry uint32

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 CreateSessionWithDomain

func CreateSessionWithDomain(store kv.Storage, dom *domain.Domain) (*session, error)

CreateSessionWithDomain creates a new Session and binds it with a Domain. We need this because when we start DDL in Domain, the DDL need a session to change some system tables. But at that time, we have been already in a lock context, which cause we can't call createSession directly.

func DisableStats4Test

func DisableStats4Test()

DisableStats4Test disables the stats for tests.

func Exist

func Exist(filename string) bool

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(code ErrorCode, lang string) string

GetErrorMessage 获取审核信息,默认为英文

func GetIndexUsageSyncLease

func GetIndexUsageSyncLease() time.Duration

GetIndexUsageSyncLease returns the index usage sync lease time.

func GetPlanReplayerGCLease

func GetPlanReplayerGCLease() time.Duration

GetPlanReplayerGCLease returns the plan replayer gc lease time.

func GetRows4Test

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 GetTimeValue

func GetTimeValue(ctx sessionctx.Context, v interface{}, tp byte, fsp int8) (d types.Datum, err error)

GetTimeValue gets the time value with type tp.

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 IsBit

func IsBit(val interface{}) bool

IsBit 判断Bit类型和值

func IsCurrentTimestampExpr

func IsCurrentTimestampExpr(e ast.ExprNode) bool

IsCurrentTimestampExpr returns whether e is CurrentTimestamp expression.

func IsNumeric

func IsNumeric(val interface{}) bool

IsNumeric 判断是否为数字

func Max

func Max(x, y int) int

func Max8

func Max8(x, y uint8) uint8

func Max64

func Max64(x, y int64) int64

func Min

func Min(x, y int) int

func NewInception

func NewInception() *session

func Parse

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

Parse parses a query string to raw ast.StmtNode.

func PostgreSQLstatisticsTableSQL

func PostgreSQLstatisticsTableSQL() string

func ResetMockAutoRandIDRetryCount

func ResetMockAutoRandIDRetryCount(failTimes int64)

ResetMockAutoRandIDRetryCount set the number of occurrences of `kv.ErrTxnRetryable` when calling TxnState.Commit().

func ResetStoreForWithTiKVTest

func ResetStoreForWithTiKVTest(store kv.Storage)

ResetStoreForWithTiKVTest is only used in the test code. TODO: Remove domap and storeBootstrapped. Use store.SetOption() to do it.

func ResultSetToStringSlice

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

ResultSetToStringSlice changes the RecordSet to [][]string.

func Reverse

func Reverse(arr []string) []string

Reverse 数组倒序

func SetIndexUsageSyncLease

func SetIndexUsageSyncLease(lease time.Duration)

SetIndexUsageSyncLease changes the default index usage sync lease time for loading info.

func SetPlanReplayerGCLease

func SetPlanReplayerGCLease(lease time.Duration)

SetPlanReplayerGCLease changes the default plan repalyer gc lease time.

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 BackupTable

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

BackupTable 表$_$inception_backup_information$_$相关信息

type ChanOscData

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

type Change

type Change struct {
	Kind         string        `json:"kind"`
	Schema       string        `json:"schema"`
	Table        string        `json:"table"`
	ColumnNames  []string      `json:"columnnames,omitempty"`  // Only present in INSERT/UPDATE
	ColumnTypes  []string      `json:"columntypes,omitempty"`  // Only present in INSERT/UPDATE
	ColumnValues []interface{} `json:"columnvalues,omitempty"` // Only present in INSERT/UPDATE
	OldKeys      *OldKeys      `json:"oldkeys,omitempty"`      // Present in DELETE and UPDATE
}

type DBInfo

type DBInfo struct {
	Name string
	// 是否已删除
	IsDeleted bool
	// 是否为新增
	IsNew bool
}

DBInfo 库信息

type ErrExprLoc

type ErrExprLoc struct {
	Offset int
	Loc    string
}

ErrExprLoc is for generate the ErrFieldNotInGroupBy error info

type ErrorCode

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_WRONG_SCHEMA_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
	ErrUnknownCharset
	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_CANT_ADD_PK_OR_UK_COLUMN
	ER_DUP_INDEX
	ER_INDEX_COLUMN_REPEAT
	ER_TEMP_TABLE_TMP_PREFIX
	ER_TABLE_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_CANT_DROP_INDEX_COLUMN
	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_SCHEMA_NOT_EXISTED_ERROR
	ER_TABLE_EXISTS_ERROR
	ER_TABLE_GROUP_EXISTS_ERROR
	ER_TABLE_GROUP_NOT_EXISTED_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_IDENT_USE_CUSTOM_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_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
	ErrColumnsMustHaveIndex
	ErrColumnsMustHaveIndexTypeErr
	ER_PRIMARY_CANT_HAVE_NULL
	ErrCantRemoveAllFields
	ErrNotFoundTableInfo
	ErrMariaDBRollbackWarn
	ErrNotFoundMasterStatus
	ErrNonUniqTable
	ErrWrongUsage
	ErrDataTooLong
	ErrCharsetNotSupport
	ErrCollationNotSupport
	ErrTableCollationNotSupport
	ErrJsonTypeSupport
	ErrEngineNotSupport
	ErrMixOfGroupFuncAndFields
	ErrFieldNotInGroupBy
	ErCantChangeColumnPosition
	ErCantChangeColumn
	ER_DATETIME_DEFAULT
	ER_TOO_MUCH_AUTO_DATETIME_COLS
	ErrFloatDoubleToDecimal
	ErrIdentifierUpper
	ErrIdentifierLower
	ErrWrongAndExpr
	ErrCannotAddForeign
	ErrWrongFkDefWithMatch
	ErrFkDupName
	ErrJoinNoOnCondition
	ErrImplicitTypeConversion
	ErrUseValueExpr
	ErrUseIndexVisibility
	ErrViewSupport
	ErrViewColumnCount
	ErrIncorrectDateTimeValue
	ErrSameNamePartition
	ErrRepeatConstDefinition
	ErrPartitionNotExisted
	ErrIndexNotExisted
	ErrMaxVarcharLength
	ErrMaxColumnCount
	ER_ERROR_LAST
	ErrUniqueKeyNeedAllFieldsInPf
	ER_PROCEDURE_NOT_EXISTED_ERROR
	ER_PROCEDURE_EXISTS_ERROR
	ER_FUNCTION_NOT_EXISTED_ERROR
	ER_FUNCTION_EXISTS_ERROR
	ER_CANT_DROP_FUNCTION
	ER_CANT_DROP_PROCEDURE
	ER_PROCEDURE_NOT_ALLOWED
	ER_FUNCTION_NOT_ALLOWED
	ER_SEQUENCE_NOT_EXISTED_ERROR
	ER_SEQUENCE_EXISTS_ERROR
	ER_INVALID_NO_GEOMETRY_DEFAULT
	ER_TRIGGER_NOT_ALLOWED
	ER_CANT_DROP_TRIGGER
	ER_TRIGGER_NOT_EXISTED_ERROR
	ER_TRIGGER_EXISTS_ERROR
	ER_TOOL_BASED_UNIQUE_INDEX_WARNING
	ER_CANT_DROP_DEPENDENCY_COLUMN
	ErrRangeNotIncreasing
	ErrWrongTypeColumnValue
	ErrValuesIsNotIntType
	ErrFieldTypeNotAllowedAsPartitionField
)

func (ErrorCode) String

func (e ErrorCode) String() string

type ExecStmtVarKeyType

type ExecStmtVarKeyType int

ExecStmtVarKeyType is a dummy type to avoid naming collision in context.

const ExecStmtVarKey ExecStmtVarKeyType = 0

ExecStmtVarKey is a variable key for ExecStmt.

func (ExecStmtVarKeyType) String

func (k ExecStmtVarKeyType) String() string

String defines a Stringer function for debugging and pretty printing.

type ExplainInfo

type ExplainInfo struct {
	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         int64   `gorm:"Column:rows"`
	Filtered     float32 `gorm:"Column:filtered"`
	Extra        string  `gorm:"Column:Extra"`

	// TiDB的Explain预估行数存储在Count中
	Count string `gorm:"Column:count"`
	// TiDB (v4.0及之后)的Explain预估行数存储在Count中
	EstRows string `gorm:"Column:estRows"`
}

ExplainInfo 执行计划信息

type FieldInfo

type FieldInfo struct {
	Table      string  `gorm:"-"`
	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:"-"`
	// contains filtered or unexported fields
}

FieldInfo 字段信息

func (*FieldInfo) IsGenerated

func (f *FieldInfo) IsGenerated() bool

IsGenerated 是否为计算列

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 LazyTxn

type LazyTxn struct {
	// States of a LazyTxn 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
}

LazyTxn 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 (*LazyTxn) CacheTableInfo

func (txn *LazyTxn) CacheTableInfo(id int64, info *model.TableInfo)

CacheTableInfo caches the index name.

func (*LazyTxn) Commit

func (txn *LazyTxn) Commit(ctx context.Context) error

Commit overrides the Transaction interface.

func (*LazyTxn) GetOption

func (txn *LazyTxn) GetOption(opt int) interface{}

GetOption implements the GetOption

func (*LazyTxn) GetTableInfo

func (txn *LazyTxn) GetTableInfo(id int64) *model.TableInfo

GetTableInfo returns the cached index name.

func (*LazyTxn) GoString

func (txn *LazyTxn) GoString() string

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

func (*LazyTxn) KeysNeedToLock

func (txn *LazyTxn) KeysNeedToLock() ([]kv.Key, error)

KeysNeedToLock returns the keys need to be locked.

func (*LazyTxn) LockKeys

func (txn *LazyTxn) LockKeys(ctx context.Context, lockCtx *kv.LockCtx, keys ...kv.Key) error

LockKeys Wrap the inner transaction's `LockKeys` to record the status

func (*LazyTxn) Rollback

func (txn *LazyTxn) Rollback() error

Rollback overrides the Transaction interface.

func (*LazyTxn) Size

func (txn *LazyTxn) Size() int

Size implements the MemBuffer interface.

func (*LazyTxn) String

func (txn *LazyTxn) String() string

func (*LazyTxn) Valid

func (txn *LazyTxn) Valid() bool

Valid implements the kv.Transaction interface.

type LevelSets

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

func NewLevelSets

func NewLevelSets(count int) *LevelSets

func (*LevelSets) Append

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

func (*LevelSets) Rows

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

type MaskingFieldInfo

type MaskingFieldInfo struct {
	Index  uint16 `json:"index"`
	Field  string `json:"field"`
	Type   string `json:"type"`
	Table  string `json:"table"`
	Schema string `json:"schema"`
	Alias  string `json:"alias"`
}

MaskingFieldInfo 脱敏功能的字段信息

func Convert

func Convert(schema, table string, fs []FieldInfo) []MaskingFieldInfo

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 OceanBaseExplainInfo

type OceanBaseExplainInfo struct {
	ID       int         `json:"ID"`
	Operator string      `json:"OPERATOR"`
	Name     string      `json:"NAME"`
	EstRows  int64       `json:"EST.ROWS"`
	Cost     int         `json:"COST"`
	OutPut   interface{} `json:"output"`
}

OceanBaseExplainInfo OceanBase 执行计划标准格式

func (*OceanBaseExplainInfo) Unmarshal

func (info *OceanBaseExplainInfo) Unmarshal(data interface{}) error

Unmarshal 将数据转化为 OceanBaseExplainInfo

type OceanBaseQueryPlan

type OceanBaseQueryPlan struct {
	QueryPlan string `gorm:"Column:Query Plan"`
}

OceanBaseQueryPlan OceanBase 执行计划信息

type OldKeys

type OldKeys struct {
	KeyNames  []string      `json:"keynames"`
	KeyTypes  []string      `json:"keytypes"`
	KeyValues []interface{} `json:"keyvalues"`
}

type Opt

type Opt struct {
	PreparedPlanCache *kvcache.SimpleLRUCache
}

Opt describes the option for creating session

type PartitionInfo

type PartitionInfo struct {
	gorm.Model

	Table           string `gorm:"Column:Table"`
	PartName        string `gorm:"Column:PARTITION_NAME"`
	PartMethod      string `gorm:"Column:PARTITION_METHOD"`
	PartExpression  string `gorm:"Column:PARTITION_EXPRESSION"`
	PartDescription string `gorm:"Column:PARTITION_DESCRIPTION"`
	TableRows       int    `gorm:"Column:TABLE_ROWS"`

	IsDeleted bool `gorm:"-"`
}

PartitionInfo 分区信息

type PrintSets

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

func NewPrintSets

func NewPrintSets() *PrintSets

func (*PrintSets) Append

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

func (*PrintSets) Rows

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 int64

	// 备份库的库名
	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
	SequencesInfo *SequencesInfo
	// ddl回滚
	DDLRollback string
	OPID        string

	ExecComplete bool

	// update/delete多表时,记录多余的表
	// update多表时,默认set第一列的表为主表,其余表才会记录到该处
	// delete多表时,默认delete后第一个表为主表,其余表才会记录到该处
	// 仅在发现多表操作时,初始化该参数
	MultiTables map[string]*TableInfo

	// 判断该语句是否是需要被合并的(只有 alter table, create index, drop index三种语句需要被合并),不需要为0,已经被合并过的SQL会被设置为-1,需要的数字为对应的合并后的SQL的行号
	NeedMerge int
	// 获取PostgreSQL wal日志SQL
	WalSql string
	// contains filtered or unexported fields
}

func (*Record) List

func (r *Record) List() []interface{}

type ReturningValues

type ReturningValues struct {
	Xmin uint32 `gorm:"Column:xmin"`
	Xmax uint32 `gorm:"Column:xmax"`
}

type Rewrite

type Rewrite struct {
	SQL string

	Stmt sqlparser.Statement
	// contains filtered or unexported fields
}

Rewrite 用于重写SQL

func NewRewrite

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

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

func (*Rewrite) Rewrite

func (rw *Rewrite) Rewrite() error

Rewrite 入口函数

func (*Rewrite) RewriteDML2Select

func (rw *Rewrite) RewriteDML2Select() error

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

func (*Rewrite) TestSelect2Count

func (rw *Rewrite) TestSelect2Count() string

type SQLError

type SQLError struct {
	Code    ErrorCode
	Level   uint8
	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.

func (*SQLError) SetLevel

func (e *SQLError) SetLevel(l uint8) *SQLError

custom error level. used for inc_level function

type SchemaAmender

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

SchemaAmender is used to amend pessimistic transactions for schema change.

func NewSchemaAmenderForTikvTxn

func NewSchemaAmenderForTikvTxn(sess *session) *SchemaAmender

NewSchemaAmenderForTikvTxn creates a schema amender for tikvTxn type.

func (*SchemaAmender) AmendTxn

AmendTxn does check and generate amend mutations based on input infoSchema and mutations, mutations need to prewrite are returned, the input commitMutations will not be changed.

type SequencesInfo

type SequencesInfo struct {
	Schema          string
	Name            string
	SequencesOption []SequencesOptionInfo
	// 是否已删除
	IsDeleted bool
	// 是否为新增
	IsNew bool
	// 备份库是否已创建
	IsCreated bool
}

SequencesInfo 库信息

type SequencesOptionInfo

type SequencesOptionInfo struct {
	gorm.Model

	SequenceOwner string `gorm:"Column:SEQUENCE_OWNER"`
	SequenceName  string `gorm:"Column:SEQUENCE_NAME"`
	StartWtih     uint64 `gorm:"Column:START_WITH"`
	MinValue      uint64 `gorm:"Column:MIN_VALUE"`
	MaxValue      uint64 `gorm:"Column:MAX_VALUE"`
	IncrementBy   uint64 `gorm:"Column:INCREMENT_BY"`
	CycleFlag     uint64 `gorm:"Column:CYCLE_FLAG"`
	CacheNum      uint64 `gorm:"Column:CACHE_NUM"`
	OrderFlag     uint64 `gorm:"Column:ORDER_FLAG"`
	CacheSize     uint64 `gorm:"Column:CACHE_SIZE"`
}

SequencesOptionInfo 序列选项信息

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.
	LastMessage() string  // LastMessage is the info message that may be generated by last command
	AffectedRows() uint64 // Affected rows by latest executed stmt.
	// Execute is deprecated, and only used by plugins. Use ExecuteStmt() instead.
	Execute(context.Context, string) ([]sqlexec.RecordSet, error)    // Execute a sql statement.
	ExecuteInc(context.Context, string) ([]sqlexec.RecordSet, error) // Execute a sql statement.
	// ExecuteStmt executes a parsed statement.
	ExecuteStmt(context.Context, ast.StmtNode) (sqlexec.RecordSet, error)
	// Parse is deprecated, use ParseWithParams() instead.
	Parse(ctx context.Context, sql string) ([]ast.StmtNode, error)
	// ExecuteInternal is a helper around ParseWithParams() and ExecuteStmt(). It is not allowed to execute multiple statements.
	ExecuteInternal(context.Context, string, ...interface{}) (sqlexec.RecordSet, error)
	String() string // String is used to debug.
	CommitTxn(context.Context) error
	RollbackTxn(context.Context)

	// PrepareStmt executes prepare statement in binary protocol.
	MysqlPrepareStmt(sql string) (stmtID uint32, paramCount int, fields []*ast.ResultField, err error)
	// PgSQL Modified
	PrepareStmt(sql string, name string) (stmtID uint32, paramCount int, fields []*ast.ResultField, err error)

	// NeedPassword
	// PgSQL Modified
	NeedPassword(user *auth.UserIdentity) bool

	// 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
	MysqlAuth(user *auth.UserIdentity, auth []byte, salt []byte) bool
	AuthWithoutVerification(user *auth.UserIdentity) bool
	AuthPluginForUser(user *auth.UserIdentity) (string, error)
	ShowProcess() *util.ProcessInfo
	// Return the information of the txn current running
	TxnInfo() *txninfo.TxnInfo
	// PrepareTxnCtx is exported for test.
	PrepareTxnCtx(context.Context)
	// FieldList returns fields list of a table.
	FieldList(tableName string) (fields []*ast.ResultField, err error)
	SetPort(port string)

	// set cur session operations allowed when tikv disk full happens.
	SetDiskFullOpt(level kvrpcpb.DiskFullOpt)
	GetDiskFullOpt() kvrpcpb.DiskFullOpt
	ClearDiskFullOpt()

	// 用以测试
	GetAlterTablePostPart(sql string, isPtOSC bool) string
	InitDisableTypes()

	LoadOptions(opt SourceOptions) error
	Audit(ctx context.Context, sql string) ([]Record, error)
	RunExecute(ctx context.Context, sql string) ([]Record, error)
}

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

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.

func CreateSession4TestWithOpt

func CreateSession4TestWithOpt(store kv.Storage, opt *Opt) (Session, error)

CreateSession4TestWithOpt creates a new session environment for test.

func CreateSessionWithOpt

func CreateSessionWithOpt(store kv.Storage, opt *Opt) (Session, error)

CreateSessionWithOpt creates a new session environment with option. Use default option if opt is nil.

type SourceOptions

type SourceOptions struct {
	Host           string
	Port           int
	User           string
	Password       string
	Check          bool
	Execute        bool
	Backup         bool
	IgnoreWarnings bool

	// 打印语法树功能
	Print bool
	// 语法树v2功能,以列方式返回query涉及的字段列表
	Masking bool

	// 使用count(*)计算受影响行数
	RealRowCount bool
	// SELECT 查询最大执行时间
	MaxExecutionTime int
	// contains filtered or unexported fields
}

SourceOptions 线上数据库信息和审核或执行的参数

type SplitSets

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

func NewSplitSets

func NewSplitSets() *SplitSets

func (*SplitSets) Append

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

func (*SplitSets) CurrentId

func (s *SplitSets) CurrentId() int64

CurrentId 当前ID

func (*SplitSets) Increment

func (s *SplitSets) Increment()

id累加

func (*SplitSets) Rows

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(st sqlexec.Statement, stmtCtx *stmtctx.StatementContext)

Add appends a stmt to history list.

func (*StmtHistory) Count

func (h *StmtHistory) Count() int

Count returns the count of the history.

type TableGroupColumn

type TableGroupColumn struct {
	TableGroupName string `gorm:"Column:Tablegroup_name"`
	DataBaseName   string `gorm:"Column:Database_name"`
	TableName      string `gorm:"Column:Table_name"`
}

type TableInfo

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

	// 索引
	Indexes []*IndexInfo

	// 分区信息
	Partitions []*PartitionInfo

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

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

	AlterCount int

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

	// 表大小.单位MB
	TableSize uint

	// 字符集&排序规则
	Collation string

	// 字符集
	Character string

	Options []*TableOptionInfo
	// row size limit
	RowSize int
	IsCte   bool
	// contains filtered or unexported fields
}

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

func (*TableInfo) EffectiveFieldCount

func (t *TableInfo) EffectiveFieldCount() (count int)

EffectiveFieldCount 有效列数,会移除已删除列和生成列

func (*TableInfo) ValidFieldCount

func (t *TableInfo) ValidFieldCount() (count int)

ValidFieldCount 可用列

type TableOptionInfo

type TableOptionInfo struct {
	gorm.Model

	Name      string `gorm:"Column:Name"`
	Engine    string `gorm:"Column:Engine"`
	Rowformat string `gorm:"Column:Row_format"`
	Collation string `gorm:"Column:Collation"`
	Comment   string `gorm:"Column:Comment"`
}

TableOptionInfo 表选项信息

type TransactionMarkData

type TransactionMarkData struct {
	ThreadID    uint32
	LogFile     string
	LogPosition int
}

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

type WalEvent

type WalEvent struct {
	Xid    uint32   `json:"xid"`
	Change []Change `json:"change"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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