infoschema

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClusterTableSlowLog is the string constant of cluster slow query memory table.
	ClusterTableSlowLog     = "CLUSTER_SLOW_QUERY"
	ClusterTableProcesslist = "CLUSTER_PROCESSLIST"
	// ClusterTableStatementsSummary is the string constant of cluster statement summary table.
	ClusterTableStatementsSummary = "CLUSTER_STATEMENTS_SUMMARY"
	// ClusterTableStatementsSummaryHistory is the string constant of cluster statement summary history table.
	ClusterTableStatementsSummaryHistory = "CLUSTER_STATEMENTS_SUMMARY_HISTORY"
	// ClusterTableStatementsSummaryEvicted is the string constant of cluster statement summary evict table.
	ClusterTableStatementsSummaryEvicted = "CLUSTER_STATEMENTS_SUMMARY_EVICTED"
	// ClusterTableTiDBTrx is the string constant of cluster transaction running table.
	ClusterTableTiDBTrx = "CLUSTER_TIDB_TRX"
	// ClusterTableDeadlocks is the string constant of cluster dead lock table.
	ClusterTableDeadlocks = "CLUSTER_DEADLOCKS"
	// ClusterTableDeadlocks is the string constant of cluster transaction summary table.
	ClusterTableTrxSummary = "CLUSTER_TRX_SUMMARY"
	// ClusterTableMemoryUsage is the memory usage status of tidb cluster.
	ClusterTableMemoryUsage = "CLUSTER_MEMORY_USAGE"
	// ClusterTableMemoryUsageOpsHistory is the memory control operators history of tidb cluster.
	ClusterTableMemoryUsageOpsHistory = "CLUSTER_MEMORY_USAGE_OPS_HISTORY"
)

Cluster table indicates that these tables need to get data from other tidb nodes, which may get from all other nodes, or may get from the ddl owner. Cluster table list, attention: 1. the table name should be upper case. 2. For tables that need to get data from all other TiDB nodes, clusterTableName should equal to "CLUSTER_" + memTableTableName.

View Source
const (
	// TableSchemata is the string constant of infoschema table.
	TableSchemata = "SCHEMATA"
	// TableTables is the string constant of infoschema table.
	TableTables = "TABLES"
	// TableColumns is the string constant of infoschema table
	TableColumns = "COLUMNS"

	// TableStatistics is the string constant of infoschema table
	TableStatistics = "STATISTICS"
	// TableCharacterSets is the string constant of infoschema charactersets memory table
	TableCharacterSets = "CHARACTER_SETS"
	// TableCollations is the string constant of infoschema collations memory table.
	TableCollations = "COLLATIONS"

	// CatalogVal is the string constant of TABLE_CATALOG.
	CatalogVal = "def"
	// TableProfiling is the string constant of infoschema table.
	TableProfiling = "PROFILING"
	// TablePartitions is the string constant of infoschema table.
	TablePartitions = "PARTITIONS"
	// TableKeyColumn is the string constant of KEY_COLUMN_USAGE.
	TableKeyColumn = "KEY_COLUMN_USAGE"
	// TableReferConst is the string constant of REFERENTIAL_CONSTRAINTS.
	TableReferConst = "REFERENTIAL_CONSTRAINTS"
	// TableSessionVar is the string constant of SESSION_VARIABLES.
	TableSessionVar = "SESSION_VARIABLES"

	// TableConstraints is the string constant of TABLE_CONSTRAINTS.
	TableConstraints = "TABLE_CONSTRAINTS"

	// TableUserPrivileges is the string constant of infoschema user privilege table.
	TableUserPrivileges = "USER_PRIVILEGES"

	// TableEngines is the string constant of infoschema table.
	TableEngines = "ENGINES"
	// TableViews is the string constant of infoschema table.
	TableViews = "VIEWS"

	// TableCollationCharacterSetApplicability is the string constant of infoschema memory table.
	TableCollationCharacterSetApplicability = "COLLATION_CHARACTER_SET_APPLICABILITY"
	// TableProcesslist is the string constant of infoschema table.
	TableProcesslist = "PROCESSLIST"
	// TableTiDBIndexes is the string constant of infoschema table
	TableTiDBIndexes = "TIDB_INDEXES"
	// TableTiDBHotRegions is the string constant of infoschema table
	TableTiDBHotRegions = "TIDB_HOT_REGIONS"
	// TableTiDBHotRegionsHistory is the string constant of infoschema table
	TableTiDBHotRegionsHistory = "TIDB_HOT_REGIONS_HISTORY"
	// TableTiKVStoreStatus is the string constant of infoschema table
	TableTiKVStoreStatus = "TIKV_STORE_STATUS"
	// TableAnalyzeStatus is the string constant of Analyze Status
	TableAnalyzeStatus = "ANALYZE_STATUS"
	// TableTiKVRegionStatus is the string constant of infoschema table
	TableTiKVRegionStatus = "TIKV_REGION_STATUS"
	// TableTiKVRegionPeers is the string constant of infoschema table
	TableTiKVRegionPeers = "TIKV_REGION_PEERS"
	// TableTiDBServersInfo is the string constant of TiDB server information table.
	TableTiDBServersInfo = "TIDB_SERVERS_INFO"
	// TableSlowQuery is the string constant of slow query memory table.
	TableSlowQuery = "SLOW_QUERY"
	// TableClusterInfo is the string constant of cluster info memory table.
	TableClusterInfo = "CLUSTER_INFO"
	// TableClusterConfig is the string constant of cluster configuration memory table.
	TableClusterConfig = "CLUSTER_CONFIG"
	// TableClusterLog is the string constant of cluster log memory table.
	TableClusterLog = "CLUSTER_LOG"
	// TableClusterLoad is the string constant of cluster load memory table.
	TableClusterLoad = "CLUSTER_LOAD"
	// TableClusterHardware is the string constant of cluster hardware table.
	TableClusterHardware = "CLUSTER_HARDWARE"
	// TableClusterSystemInfo is the string constant of cluster system info table.
	TableClusterSystemInfo = "CLUSTER_SYSTEMINFO"
	// TableTiFlashReplica is the string constant of tiflash replica table.
	TableTiFlashReplica = "TIFLASH_REPLICA"
	// TableInspectionResult is the string constant of inspection result table.
	TableInspectionResult = "INSPECTION_RESULT"
	// TableMetricTables is a table that contains all metrics table definition.
	TableMetricTables = "METRICS_TABLES"
	// TableMetricSummary is a summary table that contains all metrics.
	TableMetricSummary = "METRICS_SUMMARY"
	// TableMetricSummaryByLabel is a metric table that contains all metrics that group by label info.
	TableMetricSummaryByLabel = "METRICS_SUMMARY_BY_LABEL"
	// TableInspectionSummary is the string constant of inspection summary table.
	TableInspectionSummary = "INSPECTION_SUMMARY"
	// TableInspectionRules is the string constant of currently implemented inspection and summary rules.
	TableInspectionRules = "INSPECTION_RULES"
	// TableDDLJobs is the string constant of DDL job table.
	TableDDLJobs = "DDL_JOBS"
	// TableSequences is the string constant of all sequences created by user.
	TableSequences = "SEQUENCES"
	// TableStatementsSummary is the string constant of statement summary table.
	TableStatementsSummary = "STATEMENTS_SUMMARY"
	// TableStatementsSummaryHistory is the string constant of statements summary history table.
	TableStatementsSummaryHistory = "STATEMENTS_SUMMARY_HISTORY"
	// TableStatementsSummaryEvicted is the string constant of statements summary evicted table.
	TableStatementsSummaryEvicted = "STATEMENTS_SUMMARY_EVICTED"
	// TableStorageStats is a table that contains all tables disk usage
	TableStorageStats = "TABLE_STORAGE_STATS"
	// TableTiFlashTables is the string constant of tiflash tables table.
	TableTiFlashTables = "TIFLASH_TABLES"
	// TableTiFlashSegments is the string constant of tiflash segments table.
	TableTiFlashSegments = "TIFLASH_SEGMENTS"
	// TableClientErrorsSummaryGlobal is the string constant of client errors table.
	TableClientErrorsSummaryGlobal = "CLIENT_ERRORS_SUMMARY_GLOBAL"
	// TableClientErrorsSummaryByUser is the string constant of client errors table.
	TableClientErrorsSummaryByUser = "CLIENT_ERRORS_SUMMARY_BY_USER"
	// TableClientErrorsSummaryByHost is the string constant of client errors table.
	TableClientErrorsSummaryByHost = "CLIENT_ERRORS_SUMMARY_BY_HOST"
	// TableTiDBTrx is current running transaction status table.
	TableTiDBTrx = "TIDB_TRX"
	// TableDeadlocks is the string constant of deadlock table.
	TableDeadlocks = "DEADLOCKS"
	// TableDataLockWaits is current lock waiting status table.
	TableDataLockWaits = "DATA_LOCK_WAITS"
	// TableAttributes is the string constant of attributes table.
	TableAttributes = "ATTRIBUTES"
	// TablePlacementPolicies is the string constant of placement policies table.
	TablePlacementPolicies = "PLACEMENT_POLICIES"
	// TableTrxSummary is the string constant of transaction summary table.
	TableTrxSummary = "TRX_SUMMARY"
	// TableVariablesInfo is the string constant of variables_info table.
	TableVariablesInfo = "VARIABLES_INFO"
	// TableUserAttributes is the string constant of user_attributes view.
	TableUserAttributes = "USER_ATTRIBUTES"
	// TableMemoryUsage is the memory usage status of tidb instance.
	TableMemoryUsage = "MEMORY_USAGE"
	// TableMemoryUsageOpsHistory is the memory control operators history.
	TableMemoryUsageOpsHistory = "MEMORY_USAGE_OPS_HISTORY"
)
View Source
const (
	// DataLockWaitsColumnKey is the name of the KEY column of the DATA_LOCK_WAITS table.
	DataLockWaitsColumnKey = "KEY"
	// DataLockWaitsColumnKeyInfo is the name of the KEY_INFO column of the DATA_LOCK_WAITS table.
	DataLockWaitsColumnKeyInfo = "KEY_INFO"
	// DataLockWaitsColumnTrxID is the name of the TRX_ID column of the DATA_LOCK_WAITS table.
	DataLockWaitsColumnTrxID = "TRX_ID"
	// DataLockWaitsColumnCurrentHoldingTrxID is the name of the CURRENT_HOLDING_TRX_ID column of the DATA_LOCK_WAITS table.
	DataLockWaitsColumnCurrentHoldingTrxID = "CURRENT_HOLDING_TRX_ID"
	// DataLockWaitsColumnSQLDigest is the name of the SQL_DIGEST column of the DATA_LOCK_WAITS table.
	DataLockWaitsColumnSQLDigest = "SQL_DIGEST"
	// DataLockWaitsColumnSQLDigestText is the name of the SQL_DIGEST_TEXT column of the DATA_LOCK_WAITS table.
	DataLockWaitsColumnSQLDigestText = "SQL_DIGEST_TEXT"
)
View Source
const (
	// PrimaryKeyType is the string constant of PRIMARY KEY.
	PrimaryKeyType = "PRIMARY KEY"
	// PrimaryConstraint is the string constant of PRIMARY.
	PrimaryConstraint = "PRIMARY"
	// UniqueKeyType is the string constant of UNIQUE.
	UniqueKeyType = "UNIQUE"
	// ForeignKeyType is the string constant of Foreign Key.
	ForeignKeyType = "FOREIGN KEY"
)

Variables

View Source
var (
	// ErrDatabaseExists returns for database already exists.
	ErrDatabaseExists = dbterror.ClassSchema.NewStd(mysql.ErrDBCreateExists)
	// ErrDatabaseDropExists returns for dropping a non-existent database.
	ErrDatabaseDropExists = dbterror.ClassSchema.NewStd(mysql.ErrDBDropExists)
	// ErrAccessDenied return when the user doesn't have the permission to access the table.
	ErrAccessDenied = dbterror.ClassSchema.NewStd(mysql.ErrAccessDenied)
	// ErrDatabaseNotExists returns for database not exists.
	ErrDatabaseNotExists = dbterror.ClassSchema.NewStd(mysql.ErrBadDB)
	// ErrPlacementPolicyExists returns for placement_policy policy already exists.
	ErrPlacementPolicyExists = dbterror.ClassSchema.NewStd(mysql.ErrPlacementPolicyExists)
	// ErrPlacementPolicyNotExists return for placement_policy policy not exists.
	ErrPlacementPolicyNotExists = dbterror.ClassSchema.NewStd(mysql.ErrPlacementPolicyNotExists)
	// ErrReservedSyntax  for internal syntax.
	ErrReservedSyntax = dbterror.ClassSchema.NewStd(mysql.ErrReservedSyntax)
	// ErrTableExists returns for table already exists.
	ErrTableExists = dbterror.ClassSchema.NewStd(mysql.ErrTableExists)
	// ErrTableDropExists returns for dropping a non-existent table.
	ErrTableDropExists = dbterror.ClassSchema.NewStd(mysql.ErrBadTable)
	// ErrSequenceDropExists returns for dropping a non-exist sequence.
	ErrSequenceDropExists = dbterror.ClassSchema.NewStd(mysql.ErrUnknownSequence)
	// ErrColumnNotExists returns for column not exists.
	ErrColumnNotExists = dbterror.ClassSchema.NewStd(mysql.ErrBadField)
	// ErrColumnExists returns for column already exists.
	ErrColumnExists = dbterror.ClassSchema.NewStd(mysql.ErrDupFieldName)
	// ErrKeyNameDuplicate returns for index duplicate when rename index.
	ErrKeyNameDuplicate = dbterror.ClassSchema.NewStd(mysql.ErrDupKeyName)
	// ErrNonuniqTable returns when none unique tables errors.
	ErrNonuniqTable = dbterror.ClassSchema.NewStd(mysql.ErrNonuniqTable)
	// ErrMultiplePriKey returns for multiple primary keys.
	ErrMultiplePriKey = dbterror.ClassSchema.NewStd(mysql.ErrMultiplePriKey)
	// ErrTooManyKeyParts returns for too many key parts.
	ErrTooManyKeyParts = dbterror.ClassSchema.NewStd(mysql.ErrTooManyKeyParts)
	// ErrForeignKeyNotExists returns for foreign key not exists.
	ErrForeignKeyNotExists = dbterror.ClassSchema.NewStd(mysql.ErrCantDropFieldOrKey)
	// ErrTableNotLockedForWrite returns for write tables when only hold the table read lock.
	ErrTableNotLockedForWrite = dbterror.ClassSchema.NewStd(mysql.ErrTableNotLockedForWrite)
	// ErrTableNotLocked returns when session has explicitly lock tables, then visit unlocked table will return this error.
	ErrTableNotLocked = dbterror.ClassSchema.NewStd(mysql.ErrTableNotLocked)
	// ErrTableNotExists returns for table not exists.
	ErrTableNotExists = dbterror.ClassSchema.NewStd(mysql.ErrNoSuchTable)
	// ErrKeyNotExists returns for index not exists.
	ErrKeyNotExists = dbterror.ClassSchema.NewStd(mysql.ErrKeyDoesNotExist)
	// ErrCannotAddForeign returns for foreign key exists.
	ErrCannotAddForeign = dbterror.ClassSchema.NewStd(mysql.ErrCannotAddForeign)
	// ErrForeignKeyNotMatch returns for foreign key not match.
	ErrForeignKeyNotMatch = dbterror.ClassSchema.NewStd(mysql.ErrWrongFkDef)
	// ErrIndexExists returns for index already exists.
	ErrIndexExists = dbterror.ClassSchema.NewStd(mysql.ErrDupIndex)
	// ErrUserDropExists returns for dropping a non-existent user.
	ErrUserDropExists = dbterror.ClassSchema.NewStd(mysql.ErrBadUser)
	// ErrUserAlreadyExists return for creating a existent user.
	ErrUserAlreadyExists = dbterror.ClassSchema.NewStd(mysql.ErrUserAlreadyExists)
	// ErrTableLocked returns when the table was locked by other session.
	ErrTableLocked = dbterror.ClassSchema.NewStd(mysql.ErrTableLocked)
	// ErrWrongObject returns when the table/view/sequence is not the expected object.
	ErrWrongObject = dbterror.ClassSchema.NewStd(mysql.ErrWrongObject)
	// ErrAdminCheckTable returns when the check table in temporary mode.
	ErrAdminCheckTable = dbterror.ClassSchema.NewStd(mysql.ErrAdminCheckTable)
	// ErrEmptyDatabase returns when the database is unexpectedly empty.
	ErrEmptyDatabase = dbterror.ClassSchema.NewStd(mysql.ErrBadDB)
	// ErrForbidSchemaChange returns when the schema change is illegal
	ErrForbidSchemaChange = dbterror.ClassSchema.NewStd(mysql.ErrForbidSchemaChange)
	// ErrTableWithoutPrimaryKey returns when there is no primary key on a table and sql_require_primary_key is set
	ErrTableWithoutPrimaryKey = dbterror.ClassSchema.NewStd(mysql.ErrTableWithoutPrimaryKey)
	// ErrForeignKeyCannotUseVirtualColumn returns when foreign key refer virtual generated column.
	ErrForeignKeyCannotUseVirtualColumn = dbterror.ClassSchema.NewStd(mysql.ErrForeignKeyCannotUseVirtualColumn)
	// ErrForeignKeyCannotOpenParent returns when foreign key refer table not exists.
	ErrForeignKeyCannotOpenParent = dbterror.ClassSchema.NewStd(mysql.ErrForeignKeyCannotOpenParent)
	// ErrForeignKeyNoColumnInParent returns when foreign key refer columns don't exist in parent table.
	ErrForeignKeyNoColumnInParent = dbterror.ClassSchema.NewStd(mysql.ErrForeignKeyNoColumnInParent)
	// ErrForeignKeyNoIndexInParent returns when foreign key refer columns don't have related index in parent table.
	ErrForeignKeyNoIndexInParent = dbterror.ClassSchema.NewStd(mysql.ErrForeignKeyNoIndexInParent)
	// ErrForeignKeyColumnNotNull returns when foreign key with SET NULL constrain and the related column has not null.
	ErrForeignKeyColumnNotNull = dbterror.ClassSchema.NewStd(mysql.ErrForeignKeyColumnNotNull)
)
View Source
var MetricTableMap = map[string]MetricTableDef{}/* 639 elements not displayed */

MetricTableMap records the metric table definition, export for test. TODO: read from system table.

View Source
var TableTiDBHotRegionsCols = []columnInfo{
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
}

TableTiDBHotRegionsCols is TiDB hot region mem table columns.

View Source
var TableTiDBHotRegionsHistoryCols = []columnInfo{
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
}

TableTiDBHotRegionsHistoryCols is TiDB hot region history mem table columns.

View Source
var TableTiKVRegionPeersCols = []columnInfo{
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
}

TableTiKVRegionPeersCols is TiKV region peers mem table columns.

View Source
var TableTiKVRegionStatusCols = []columnInfo{
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
}

TableTiKVRegionStatusCols is TiKV region status mem table columns.

View Source
var TableTiKVStoreStatusCols = []columnInfo{
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
	{/* contains filtered or unexported fields */},
}

TableTiKVStoreStatusCols is TiDB kv store status columns.

Functions

func AppendHostInfoToRows

func AppendHostInfoToRows(ctx sessionctx.Context, rows [][]types.Datum) ([][]types.Datum, error)

AppendHostInfoToRows appends host info to the rows.

func ConvertCharsetCollateToLowerCaseIfNeed

func ConvertCharsetCollateToLowerCaseIfNeed(tbInfo *model.TableInfo)

ConvertCharsetCollateToLowerCaseIfNeed convert the charset / collation of table and its columns to lower case, if the table's version is prior to TableInfoVersion3.

func ConvertOldVersionUTF8ToUTF8MB4IfNeed

func ConvertOldVersionUTF8ToUTF8MB4IfNeed(tbInfo *model.TableInfo)

ConvertOldVersionUTF8ToUTF8MB4IfNeed convert old version UTF8 to UTF8MB4 if config.TreatOldVersionUTF8AsUTF8MB4 is enable.

func FormatStoreServerVersion

func FormatStoreServerVersion(version string) string

FormatStoreServerVersion format version of store servers(Tikv or TiFlash)

func FormatTiDBVersion

func FormatTiDBVersion(TiDBVersion string, isDefaultVersion bool) string

FormatTiDBVersion make TiDBVersion consistent to TiKV and PD. The default TiDBVersion is 5.7.25-TiDB-${TiDBReleaseVersion}.

func GenLabelConditionValues

func GenLabelConditionValues(values set.StringSet) string

GenLabelConditionValues generates the label condition values.

func GetDataFromSessionVariables

func GetDataFromSessionVariables(ctx context.Context, sctx sessionctx.Context) ([][]types.Datum, error)

GetDataFromSessionVariables return the [name, value] of all session variables

func GetInstanceAddr

func GetInstanceAddr(ctx sessionctx.Context) (string, error)

GetInstanceAddr gets the instance address.

func GetSequenceByName

func GetSequenceByName(is InfoSchema, schema, sequence model.CIStr) (util.SequenceTable, error)

GetSequenceByName gets the sequence by name.

func GetShardingInfo

func GetShardingInfo(dbInfo *model.DBInfo, tableInfo *model.TableInfo) interface{}

GetShardingInfo returns a nil or description string for the sharding information of given TableInfo. The returned description string may be:

  • "NOT_SHARDED": for tables that SHARD_ROW_ID_BITS is not specified.
  • "NOT_SHARDED(PK_IS_HANDLE)": for tables of which primary key is row id.
  • "PK_AUTO_RANDOM_BITS={bit_number}, RANGE BITS={bit_number}": for tables of which primary key is sharded row id.
  • "SHARD_BITS={bit_number}": for tables that with SHARD_ROW_ID_BITS.

The returned nil indicates that sharding information is not suitable for the table(for example, when the table is a View). This function is exported for unit test.

func GetTableTiDBHotRegionsHistoryCols

func GetTableTiDBHotRegionsHistoryCols() []columnInfo

GetTableTiDBHotRegionsHistoryCols is to get TableTiDBHotRegionsHistoryCols. It is an optimization because Go does’t support const arrays. The solution is to use initialization functions. It is useful in the BCE optimization. https://go101.org/article/bounds-check-elimination.html

func GetTableTiKVRegionPeersCols

func GetTableTiKVRegionPeersCols() []columnInfo

GetTableTiKVRegionPeersCols is to get TableTiKVRegionPeersCols. It is an optimization because Go does’t support const arrays. The solution is to use initialization functions. It is useful in the BCE optimization. https://go101.org/article/bounds-check-elimination.html

func GetTiFlashStoreCount

func GetTiFlashStoreCount(ctx sessionctx.Context) (cnt uint64, err error)

GetTiFlashStoreCount returns the count of tiflash server.

func HasAutoIncrementColumn

func HasAutoIncrementColumn(tbInfo *model.TableInfo) (bool, string)

HasAutoIncrementColumn checks whether the table has auto_increment columns, if so, return true and the column name.

func IsMetricTable

func IsMetricTable(lowerTableName string) bool

IsMetricTable uses to checks whether the table is a metric table.

func RegisterVirtualTable

func RegisterVirtualTable(dbInfo *model.DBInfo, tableFromMeta tableFromMetaFunc)

RegisterVirtualTable register virtual tables to the builder.

func SysVarHiddenForSem

func SysVarHiddenForSem(ctx sessionctx.Context, sysVarNameInLower string) bool

SysVarHiddenForSem checks if a given sysvar is hidden according to SEM and privileges.

Types

type Builder

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

Builder builds a new InfoSchema.

func NewBuilder

func NewBuilder(store kv.Storage, factory func() (pools.Resource, error)) *Builder

NewBuilder creates a new Builder with a Handle.

func (*Builder) ApplyDiff

func (b *Builder) ApplyDiff(m *meta.Meta, diff *model.SchemaDiff) ([]int64, error)

ApplyDiff applies SchemaDiff to the new InfoSchema. Return the detail updated table IDs that are produced from SchemaDiff and an error.

func (*Builder) Build

func (b *Builder) Build() InfoSchema

Build builds and returns the built infoschema.

func (*Builder) InitWithDBInfos

func (b *Builder) InitWithDBInfos(dbInfos []*model.DBInfo, policies []*model.PolicyInfo, schemaVersion int64) (*Builder, error)

InitWithDBInfos initializes an empty new InfoSchema with a slice of DBInfo, all placement rules, and schema version.

func (*Builder) InitWithOldInfoSchema

func (b *Builder) InitWithOldInfoSchema(oldSchema InfoSchema) *Builder

InitWithOldInfoSchema initializes an empty new InfoSchema by copies all the data from old InfoSchema.

func (*Builder) SetDeltaUpdateBundles

func (b *Builder) SetDeltaUpdateBundles()

type ClusterTableCopDestination

type ClusterTableCopDestination int

ClusterTableCopDestination means the destination that cluster tables will send cop requests to.

const (
	// AllTiDB is uese by CLUSTER_* table, means that these tables will send cop request to all TiDB nodes.
	AllTiDB ClusterTableCopDestination = iota
	// DDLOwner is uese by tiflash_replica currently, means that this table will send cop request to DDL owner node.
	DDLOwner
)

func GetClusterTableCopDestination

func GetClusterTableCopDestination(tableName string) ClusterTableCopDestination

GetClusterTableCopDestination gets cluster table cop request destination.

type InfoCache

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

InfoCache handles information schema, including getting and setting. The cache behavior, however, is transparent and under automatic management. It only promised to cache the infoschema, if it is newer than all the cached.

func NewCache

func NewCache(capcity int) *InfoCache

NewCache creates a new InfoCache.

func (*InfoCache) GetBySnapshotTS

func (h *InfoCache) GetBySnapshotTS(snapshotTS uint64) InfoSchema

GetBySnapshotTS gets the information schema based on snapshotTS. If the snapshotTS is new than maxUpdatedSnapshotTS, that's mean it can directly use the latest infoschema. otherwise, will return nil.

func (*InfoCache) GetByVersion

func (h *InfoCache) GetByVersion(version int64) InfoSchema

GetByVersion gets the information schema based on schemaVersion. Returns nil if it is not loaded.

func (*InfoCache) GetLatest

func (h *InfoCache) GetLatest() InfoSchema

GetLatest gets the newest information schema.

func (*InfoCache) Insert

func (h *InfoCache) Insert(is InfoSchema, snapshotTS uint64) bool

Insert will **TRY** to insert the infoschema into the cache. It only promised to cache the newest infoschema. It returns 'true' if it is cached, 'false' otherwise.

type InfoSchema

type InfoSchema interface {
	SchemaByName(schema model.CIStr) (*model.DBInfo, bool)
	SchemaExists(schema model.CIStr) bool
	TableByName(schema, table model.CIStr) (table.Table, error)
	TableExists(schema, table model.CIStr) bool
	SchemaByID(id int64) (*model.DBInfo, bool)
	SchemaByTable(tableInfo *model.TableInfo) (*model.DBInfo, bool)
	PolicyByName(name model.CIStr) (*model.PolicyInfo, bool)
	TableByID(id int64) (table.Table, bool)
	AllocByID(id int64) (autoid.Allocators, bool)
	AllSchemaNames() []string
	AllSchemas() []*model.DBInfo
	Clone() (result []*model.DBInfo)
	SchemaTables(schema model.CIStr) []table.Table
	SchemaMetaVersion() int64
	// TableIsView indicates whether the schema.table is a view.
	TableIsView(schema, table model.CIStr) bool
	// TableIsSequence indicates whether the schema.table is a sequence.
	TableIsSequence(schema, table model.CIStr) bool
	FindTableByPartitionID(partitionID int64) (table.Table, *model.DBInfo, *model.PartitionDefinition)
	// PlacementBundleByPhysicalTableID is used to get a rule bundle.
	PlacementBundleByPhysicalTableID(id int64) (*placement.Bundle, bool)
	// AllPlacementBundles is used to get all placement bundles
	AllPlacementBundles() []*placement.Bundle
	// AllPlacementPolicies returns all placement policies
	AllPlacementPolicies() []*model.PolicyInfo
	// HasTemporaryTable returns whether information schema has temporary table
	HasTemporaryTable() bool
	// GetTableReferredForeignKeys gets the table's ReferredFKInfo by lowercase schema and table name.
	GetTableReferredForeignKeys(schema, table string) []*model.ReferredFKInfo
}

InfoSchema is the interface used to retrieve the schema information. It works as a in memory cache and doesn't handle any schema change. InfoSchema is read-only, and the returned value is a copy. TODO: add more methods to retrieve tables and columns.

func MockInfoSchema

func MockInfoSchema(tbList []*model.TableInfo) InfoSchema

MockInfoSchema only serves for test.

func MockInfoSchemaWithSchemaVer

func MockInfoSchemaWithSchemaVer(tbList []*model.TableInfo, schemaVer int64) InfoSchema

MockInfoSchemaWithSchemaVer only serves for test.

type MetricTableDef

type MetricTableDef struct {
	PromQL   string
	Labels   []string
	Quantile float64
	Comment  string
}

MetricTableDef is the metric table define.

func GetMetricTableDef

func GetMetricTableDef(lowerTableName string) (*MetricTableDef, error)

GetMetricTableDef gets the metric table define.

func (*MetricTableDef) GenPromQL

func (def *MetricTableDef) GenPromQL(sctx sessionctx.Context, labels map[string]set.StringSet, quantile float64) string

GenPromQL generates the promQL.

type SchemaAndTableName

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

SchemaAndTableName contains the lower-case schema name and table name.

type ServerInfo

type ServerInfo struct {
	ServerType     string
	Address        string
	StatusAddr     string
	Version        string
	GitHash        string
	StartTimestamp int64
	ServerID       uint64
}

ServerInfo represents the basic server information of single cluster component

func GetClusterServerInfo

func GetClusterServerInfo(ctx sessionctx.Context) ([]ServerInfo, error)

GetClusterServerInfo returns all components information of cluster

func GetPDServerInfo

func GetPDServerInfo(ctx sessionctx.Context) ([]ServerInfo, error)

GetPDServerInfo returns all PD nodes information of cluster

func GetStoreServerInfo

func GetStoreServerInfo(ctx sessionctx.Context) ([]ServerInfo, error)

GetStoreServerInfo returns all store nodes(TiKV or TiFlash) cluster information

func GetTiDBServerInfo

func GetTiDBServerInfo(ctx sessionctx.Context) ([]ServerInfo, error)

GetTiDBServerInfo returns all TiDB nodes information of cluster

func (*ServerInfo) ResolveLoopBackAddr

func (s *ServerInfo) ResolveLoopBackAddr()

ResolveLoopBackAddr exports for testing.

type SessionExtendedInfoSchema

type SessionExtendedInfoSchema struct {
	InfoSchema
	LocalTemporaryTablesOnce sync.Once
	LocalTemporaryTables     *SessionTables
	MdlTables                *SessionTables
}

SessionExtendedInfoSchema implements InfoSchema Local temporary table has a loose relationship with database. So when a database is dropped, its temporary tables still exist and can be returned by TableByName/TableByID.

func (*SessionExtendedInfoSchema) DetachTemporaryTableInfoSchema

func (ts *SessionExtendedInfoSchema) DetachTemporaryTableInfoSchema() *SessionExtendedInfoSchema

DetachTemporaryTableInfoSchema returns a new SessionExtendedInfoSchema without temporary tables

func (*SessionExtendedInfoSchema) HasTemporaryTable

func (ts *SessionExtendedInfoSchema) HasTemporaryTable() bool

HasTemporaryTable returns whether information schema has temporary table

func (*SessionExtendedInfoSchema) SchemaByTable

func (ts *SessionExtendedInfoSchema) SchemaByTable(tableInfo *model.TableInfo) (*model.DBInfo, bool)

SchemaByTable implements InfoSchema.SchemaByTable, it returns a stale DBInfo even if it's dropped.

func (*SessionExtendedInfoSchema) TableByID

func (ts *SessionExtendedInfoSchema) TableByID(id int64) (table.Table, bool)

TableByID implements InfoSchema.TableByID

func (*SessionExtendedInfoSchema) TableByName

func (ts *SessionExtendedInfoSchema) TableByName(schema, table model.CIStr) (table.Table, error)

TableByName implements InfoSchema.TableByName

func (*SessionExtendedInfoSchema) UpdateTableInfo

func (ts *SessionExtendedInfoSchema) UpdateTableInfo(db *model.DBInfo, tableInfo table.Table) error

UpdateTableInfo implements InfoSchema.SchemaByTable.

type SessionTables

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

SessionTables store local temporary tables

func NewSessionTables

func NewSessionTables() *SessionTables

NewSessionTables creates a new NewSessionTables object

func (*SessionTables) AddTable

func (is *SessionTables) AddTable(db *model.DBInfo, tbl table.Table) error

AddTable add a table

func (*SessionTables) Count

func (is *SessionTables) Count() int

Count gets the count of the temporary tables.

func (*SessionTables) RemoveTable

func (is *SessionTables) RemoveTable(schema, table model.CIStr) (exist bool)

RemoveTable remove a table

func (*SessionTables) SchemaByTable

func (is *SessionTables) SchemaByTable(tableInfo *model.TableInfo) (*model.DBInfo, bool)

SchemaByTable get a table's schema name

func (*SessionTables) TableByID

func (is *SessionTables) TableByID(id int64) (tbl table.Table, ok bool)

TableByID get table by table id

func (*SessionTables) TableByName

func (is *SessionTables) TableByName(schema, table model.CIStr) (table.Table, bool)

TableByName get table by name

func (*SessionTables) TableExists

func (is *SessionTables) TableExists(schema, table model.CIStr) (ok bool)

TableExists check if table with the name exists

type VirtualTable

type VirtualTable struct{}

VirtualTable is a dummy table.Table implementation.

func (*VirtualTable) AddRecord

func (vt *VirtualTable) AddRecord(ctx sessionctx.Context, r []types.Datum, opts ...table.AddRecordOption) (recordID kv.Handle, err error)

AddRecord implements table.Table AddRecord interface.

func (*VirtualTable) Allocators

func (vt *VirtualTable) Allocators(_ sessionctx.Context) autoid.Allocators

Allocators implements table.Table Allocators interface.

func (*VirtualTable) Cols

func (vt *VirtualTable) Cols() []*table.Column

Cols implements table.Table Cols interface.

func (*VirtualTable) DeletableCols

func (vt *VirtualTable) DeletableCols() []*table.Column

DeletableCols implements table.Table WritableCols interface.

func (*VirtualTable) FullHiddenColsAndVisibleCols

func (vt *VirtualTable) FullHiddenColsAndVisibleCols() []*table.Column

FullHiddenColsAndVisibleCols implements table FullHiddenColsAndVisibleCols interface.

func (*VirtualTable) GetPhysicalID

func (vt *VirtualTable) GetPhysicalID() int64

GetPhysicalID implements table.Table GetPhysicalID interface.

func (*VirtualTable) HiddenCols

func (vt *VirtualTable) HiddenCols() []*table.Column

HiddenCols implements table.Table HiddenCols interface.

func (*VirtualTable) IndexPrefix

func (vt *VirtualTable) IndexPrefix() kv.Key

IndexPrefix implements table.Table IndexPrefix interface.

func (*VirtualTable) Indices

func (vt *VirtualTable) Indices() []table.Index

Indices implements table.Table Indices interface.

func (*VirtualTable) Meta

func (vt *VirtualTable) Meta() *model.TableInfo

Meta implements table.Table Meta interface.

func (*VirtualTable) RecordPrefix

func (vt *VirtualTable) RecordPrefix() kv.Key

RecordPrefix implements table.Table RecordPrefix interface.

func (*VirtualTable) RemoveRecord

func (vt *VirtualTable) RemoveRecord(ctx sessionctx.Context, h kv.Handle, r []types.Datum) error

RemoveRecord implements table.Table RemoveRecord interface.

func (*VirtualTable) Type

func (vt *VirtualTable) Type() table.Type

Type implements table.Table Type interface.

func (*VirtualTable) UpdateRecord

func (vt *VirtualTable) UpdateRecord(ctx context.Context, sctx sessionctx.Context, h kv.Handle, oldData, newData []types.Datum, touched []bool) error

UpdateRecord implements table.Table UpdateRecord interface.

func (*VirtualTable) VisibleCols

func (vt *VirtualTable) VisibleCols() []*table.Column

VisibleCols implements table.Table VisibleCols interface.

func (*VirtualTable) WritableCols

func (vt *VirtualTable) WritableCols() []*table.Column

WritableCols implements table.Table WritableCols interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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