infoschema

package
v1.1.0-beta.0...-92d45d5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 69 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"
	// ClusterTableTiDBIndexUsage is a table to show the usage stats of indexes across the whole cluster.
	ClusterTableTiDBIndexUsage = "CLUSTER_TIDB_INDEX_USAGE"
)

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"
	// TableResourceGroups is the metadata of resource groups.
	TableResourceGroups = "RESOURCE_GROUPS"
	// TableRunawayWatches is the query list of runaway watch.
	TableRunawayWatches = "RUNAWAY_WATCHES"
	// TableCheckConstraints is the list of CHECK constraints.
	TableCheckConstraints = "CHECK_CONSTRAINTS"
	// TableTiDBCheckConstraints is the list of CHECK constraints, with non-standard TiDB extensions.
	TableTiDBCheckConstraints = "TIDB_CHECK_CONSTRAINTS"
	// TableKeywords is the list of keywords.
	TableKeywords = "KEYWORDS"
	// TableTiDBIndexUsage is a table to show the usage stats of indexes in the current instance.
	TableTiDBIndexUsage = "TIDB_INDEX_USAGE"
)
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"
)
View Source
const (
	// TiFlashWrite is the TiFlash write node in disaggregated mode.
	TiFlashWrite = "tiflash_write"
)

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)
	// ErrResourceGroupExists return for resource group already exists.
	ErrResourceGroupExists = dbterror.ClassSchema.NewStd(mysql.ErrResourceGroupExists)
	// ErrResourceGroupNotExists return for resource group not exists.
	ErrResourceGroupNotExists = dbterror.ClassSchema.NewStd(mysql.ErrResourceGroupNotExists)
	// ErrResourceGroupInvalidBackgroundTaskName return for unknown resource group background task name.
	ErrResourceGroupInvalidBackgroundTaskName = dbterror.ClassExecutor.NewStd(mysql.ErrResourceGroupInvalidBackgroundTaskName)
	// ErrResourceGroupInvalidForRole return for invalid resource group for role.
	ErrResourceGroupInvalidForRole = dbterror.ClassSchema.NewStd(mysql.ErrResourceGroupInvalidForRole)
	// 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)
	// ErrForeignKeyOnPartitioned returns for foreign key on partition table.
	ErrForeignKeyOnPartitioned = dbterror.ClassSchema.NewStd(mysql.ErrForeignKeyOnPartitioned)
	// 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)
	// ErrResourceGroupSupportDisabled returns for resource group feature is disabled
	ErrResourceGroupSupportDisabled = dbterror.ClassSchema.NewStd(mysql.ErrResourceGroupSupportDisabled)
	// ErrCheckConstraintDupName returns for duplicate constraint names.
	ErrCheckConstraintDupName = dbterror.ClassSchema.NewStd(mysql.ErrCheckConstraintDupName)
)
View Source
var AllPlacementPolicyAttribute specialAttributeFilter = func(t *model.TableInfo) bool {
	if t.PlacementPolicyRef != nil {
		return true
	}
	if t.Partition != nil {
		for _, def := range t.Partition.Definitions {
			if def.PlacementPolicyRef != nil {
				return true
			}
		}
	}
	return false
}

AllPlacementPolicyAttribute is the Placement Policy attribute filter used by ListTablesWithSpecialAttribute. Different from PlacementPolicyAttribute, Partition.Enable flag will be ignored.

View Source
var AllSpecialAttribute specialAttributeFilter = hasSpecialAttributes

AllSpecialAttribute marks a model.TableInfo with any special attributes.

View Source
var ForeignKeysAttribute specialAttributeFilter = func(t *model.TableInfo) bool {
	return len(t.ForeignKeys) > 0
}

ForeignKeysAttribute is the ForeignKeys attribute filter used by ListTablesWithSpecialAttribute.

View Source
var MetricTableMap = map[string]MetricTableDef{}/* 637 elements not displayed */

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

View Source
var PartitionAttribute specialAttributeFilter = func(t *model.TableInfo) bool {
	return t.GetPartitionInfo() != nil
}

PartitionAttribute is the Partition attribute filter used by ListTablesWithSpecialAttribute.

View Source
var PlacementPolicyAttribute specialAttributeFilter = func(t *model.TableInfo) bool {
	if t.PlacementPolicyRef != nil {
		return true
	}
	if parInfo := t.GetPartitionInfo(); parInfo != nil {
		for _, def := range parInfo.Definitions {
			if def.PlacementPolicyRef != nil {
				return true
			}
		}
	}
	return false
}

PlacementPolicyAttribute is the Placement Policy attribute filter used by ListTablesWithSpecialAttribute.

View Source
var TTLAttribute specialAttributeFilter = func(t *model.TableInfo) bool {
	return t.State == model.StatePublic && t.TTLInfo != nil
}

TTLAttribute is the TTL attribute filter used by ListTablesWithSpecialAttribute.

View Source
var TableLockAttribute specialAttributeFilter = func(t *model.TableInfo) bool {
	return t.Lock != nil
}

TableLockAttribute is the Table Lock attribute filter used by ListTablesWithSpecialAttribute.

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 */},
	{/* 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.

View Source
var TiFlashAttribute specialAttributeFilter = func(t *model.TableInfo) bool {
	return t.TiFlashReplica != nil
}

TiFlashAttribute is the TiFlashReplica attribute filter used by ListTablesWithSpecialAttribute.

Functions

func AllSchemaNames

func AllSchemaNames(is InfoSchema) (names []string)

AllSchemaNames returns all the schemas' names.

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 FetchClusterServerInfoWithoutPrivilegeCheck

func FetchClusterServerInfoWithoutPrivilegeCheck(ctx context.Context, vars *variable.SessionVars, serversInfo []ServerInfo, serverInfoType diagnosticspb.ServerInfoType, recordWarningInStmtCtx bool) ([][]types.Datum, error)

FetchClusterServerInfoWithoutPrivilegeCheck fetches cluster server information

func FindTableByTblOrPartID

func FindTableByTblOrPartID(is InfoSchema, id int64) (table.Table, *model.PartitionDefinition)

FindTableByTblOrPartID looks for table.Table for the given id in the InfoSchema. The id can be either a table id or a partition id. If the id is a table id, the corresponding table.Table will be returned, and the second return value is nil. If the id is a partition id, the corresponding table.Table and PartitionDefinition will be returned. If the id is not found in the InfoSchema, nil will be returned for both return values.

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 GetDataFromSessionConnectAttrs

func GetDataFromSessionConnectAttrs(sctx sessionctx.Context, sameAccount bool) ([][]types.Datum, error)

GetDataFromSessionConnectAttrs produces the rows for the session_connect_attrs table.

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 pmodel.CIStr) (util.SequenceTable, error)

GetSequenceByName gets the sequence by name.

func GetShardingInfo

func GetShardingInfo(dbInfo pmodel.CIStr, tableInfo *model.TableInfo) any

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 IsClusterTableByName

func IsClusterTableByName(dbName, tableName string) bool

IsClusterTableByName used to check whether the table is a cluster memory table. Export for PhysicalTableScan.ExplainID

func IsMetricTable

func IsMetricTable(lowerTableName string) bool

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

func IsSpecialDB

func IsSpecialDB(dbName string) bool

IsSpecialDB tells whether the database is a special database.

func IsV2

func IsV2(is InfoSchema) (bool, *infoschemaV2)

IsV2 tells whether an InfoSchema is v2 or not.

func NewInfoSchemaV2

func NewInfoSchemaV2(r autoid.Requirement, factory func() (pools.Resource, error), infoData *Data) infoschemaV2

NewInfoSchemaV2 create infoschemaV2.

func RegisterVirtualTable

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

RegisterVirtualTable register virtual tables to the builder.

func SchemaByTable

func SchemaByTable(is InfoSchema, tableInfo *model.TableInfo) (val *model.DBInfo, ok bool)

SchemaByTable get a table's schema name

func SysVarHiddenForSem

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

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

func TableIsSequence

func TableIsSequence(is InfoSchema, schema, table pmodel.CIStr) bool

TableIsSequence indicates whether the schema.table is a sequence.

func TableIsView

func TableIsView(is InfoSchema, schema, table pmodel.CIStr) bool

TableIsView indicates whether the schema.table is a view.

func WithRefillOption

func WithRefillOption(ctx context.Context, refill bool) context.Context

WithRefillOption controls the infoschema v2 cache refill operation. By default, TableByID does not refill schema cache, and TableByName does. The behavior can be changed by providing the context.Context.

Types

type Builder

type Builder struct {

	// Used by autoid allocators
	autoid.Requirement
	// contains filtered or unexported fields
}

Builder builds a new InfoSchema.

func NewBuilder

func NewBuilder(r autoid.Requirement, factory func() (pools.Resource, error), infoData *Data, useV2 bool) *Builder

NewBuilder creates a new Builder with a Handle.

func (*Builder) AllSchemaNames

func (is *Builder) AllSchemaNames() []pmodel.CIStr

func (*Builder) AllSchemas

func (is *Builder) AllSchemas() (schemas []*model.DBInfo)

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(schemaTS uint64) InfoSchema

Build builds and returns the built infoschema.

func (*Builder) CloneAndUpdateTS

func (is *Builder) CloneAndUpdateTS(startTS uint64) *infoschemaV2

func (*Builder) EvictTable

func (is *Builder) EvictTable(schema, tbl pmodel.CIStr)

EvictTable is exported for testing only.

func (*Builder) FindTableByPartitionID

func (is *Builder) FindTableByPartitionID(partitionID int64) (table.Table, *model.DBInfo, *model.PartitionDefinition)

func (*Builder) FindTableInfoByPartitionID

func (is *Builder) FindTableInfoByPartitionID(
	partitionID int64,
) (*model.TableInfo, *model.DBInfo, *model.PartitionDefinition)

FindTableInfoByPartitionID implements InfoSchema.FindTableInfoByPartitionID

func (*Builder) InitWithDBInfos

func (b *Builder) InitWithDBInfos(dbInfos []*model.DBInfo, policies []*model.PolicyInfo, resourceGroups []*model.ResourceGroupInfo, schemaVersion int64) 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) error

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

func (*Builder) IterateAllTableItems

func (is *Builder) IterateAllTableItems(visit func(TableItem) bool)

IterateAllTableItems is used for special performance optimization. Used by executor/infoschema_reader.go to handle reading from INFORMATION_SCHEMA.TABLES. If visit return false, stop the iterate process.

func (*Builder) ListTablesWithSpecialAttribute

func (is *Builder) ListTablesWithSpecialAttribute(filter specialAttributeFilter) []tableInfoResult

func (*Builder) SchemaByID

func (is *Builder) SchemaByID(id int64) (*model.DBInfo, bool)

func (*Builder) SchemaByName

func (is *Builder) SchemaByName(schema pmodel.CIStr) (val *model.DBInfo, ok bool)

func (*Builder) SchemaExists

func (is *Builder) SchemaExists(schema pmodel.CIStr) bool

func (*Builder) SchemaSimpleTableInfos

func (is *Builder) SchemaSimpleTableInfos(ctx context.Context, schema pmodel.CIStr) ([]*model.TableNameInfo, error)

SchemaSimpleTableInfos implements MetaOnlyInfoSchema.

func (*Builder) SchemaTableInfos

func (is *Builder) SchemaTableInfos(ctx context.Context, schema pmodel.CIStr) ([]*model.TableInfo, error)

SchemaTableInfos implements MetaOnlyInfoSchema.

func (*Builder) SetDeltaUpdateBundles

func (b *Builder) SetDeltaUpdateBundles()

func (*Builder) TableByID

func (is *Builder) TableByID(ctx context.Context, id int64) (val table.Table, ok bool)

TableByID implements the InfoSchema interface. As opposed to TableByName, TableByID will not refill cache when schema cache miss, unless the caller changes the behavior by passing a context use WithRefillOption.

func (*Builder) TableByName

func (is *Builder) TableByName(ctx context.Context, schema, tbl pmodel.CIStr) (t table.Table, err error)

TableByName implements the InfoSchema interface. When schema cache miss, it will fetch the TableInfo from TikV and refill cache.

func (*Builder) TableExists

func (is *Builder) TableExists(schema, table pmodel.CIStr) bool

func (*Builder) TableInfoByID

func (is *Builder) TableInfoByID(id int64) (*model.TableInfo, bool)

TableInfoByID implements InfoSchema.TableInfoByID

func (*Builder) TableInfoByName

func (is *Builder) TableInfoByName(schema, table pmodel.CIStr) (*model.TableInfo, error)

TableInfoByName implements InfoSchema.TableInfoByName

func (*Builder) WithStore

func (b *Builder) WithStore(s kv.Storage) *Builder

WithStore attaches the given store to builder.

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 Data

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

Data is the core data struct of infoschema V2.

func NewData

func NewData() *Data

NewData creates an infoschema V2 data struct.

func (*Data) CacheCapacity

func (isd *Data) CacheCapacity() uint64

CacheCapacity is exported for testing.

func (*Data) SetCacheCapacity

func (isd *Data) SetCacheCapacity(capacity uint64)

SetCacheCapacity sets the cache capacity size in bytes.

type InfoCache

type InfoCache struct {
	Data *Data
	// 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(r autoid.Requirement, capacity 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. It searches the schema cache and find the schema with max schema ts that equals or smaller than given snapshot ts Where the schema ts is the commitTs of the txn creates the schema diff

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) GetEmptySchemaVersions

func (h *InfoCache) GetEmptySchemaVersions() map[int64]struct{}

GetEmptySchemaVersions returns emptySchemaVersions, exports for testing.

func (*InfoCache) GetLatest

func (h *InfoCache) GetLatest() InfoSchema

GetLatest gets the newest information schema.

func (*InfoCache) Insert

func (h *InfoCache) Insert(is InfoSchema, schemaTS 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. schemaTs is the commitTs of the txn creates the schema diff, which indicates since when the schema version is taking effect

func (*InfoCache) InsertEmptySchemaVersion

func (h *InfoCache) InsertEmptySchemaVersion(version int64)

InsertEmptySchemaVersion inserts empty schema version into a map. If exceeded the cache capacity, remove the oldest version.

func (*InfoCache) Len

func (h *InfoCache) Len() int

Len returns the size of the cache

func (*InfoCache) ReSize

func (h *InfoCache) ReSize(capacity int)

ReSize re-size the cache.

func (*InfoCache) Reset

func (h *InfoCache) Reset(capacity int)

Reset resets the cache.

func (*InfoCache) Size

func (h *InfoCache) Size() int

Size returns the size of the cache, export for test.

func (*InfoCache) Upsert

func (h *InfoCache) Upsert(is InfoSchema, schemaTS uint64) func()

Upsert is Resert and Insert combined, used during infoschema v1 v2 switch.

type InfoSchema

type InfoSchema interface {
	context.MetaOnlyInfoSchema
	TableByName(ctx stdctx.Context, schema, table pmodel.CIStr) (table.Table, error)
	TableByID(ctx stdctx.Context, id int64) (table.Table, bool)
	FindTableByPartitionID(partitionID int64) (table.Table, *model.DBInfo, *model.PartitionDefinition)
	ListTablesWithSpecialAttribute(filter specialAttributeFilter) []tableInfoResult
	// contains filtered or unexported methods
}

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.

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(metricsSchemaRangeDuration int64, 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
	EngineRole     string
}

ServerInfo represents the basic server information of single cluster component

func FilterClusterServerInfo

func FilterClusterServerInfo(serversInfo []ServerInfo, nodeTypes, addresses set.StringSet) []ServerInfo

FilterClusterServerInfo filters serversInfo by nodeTypes and addresses

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 GetSchedulingServerInfo

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

GetSchedulingServerInfo returns all scheduling nodes information of cluster

func GetStoreServerInfo

func GetStoreServerInfo(store kv.Storage) ([]ServerInfo, error)

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

func GetTSOServerInfo

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

GetTSOServerInfo returns all TSO nodes information of cluster

func GetTiCDCServerInfo

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

GetTiCDCServerInfo gets server info of TiCDC from PD.

func GetTiDBServerInfo

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

GetTiDBServerInfo returns all TiDB nodes information of cluster

func GetTiFlashServerInfo

func GetTiFlashServerInfo(store kv.Storage) ([]ServerInfo, error)

GetTiFlashServerInfo returns all TiFlash server infos

func GetTiProxyServerInfo

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

GetTiProxyServerInfo gets server info of TiProxy from PD.

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) FindTableInfoByPartitionID

func (ts *SessionExtendedInfoSchema) FindTableInfoByPartitionID(
	partitionID int64,
) (*model.TableInfo, *model.DBInfo, *model.PartitionDefinition)

FindTableInfoByPartitionID implements InfoSchema.FindTableInfoByPartitionID

func (*SessionExtendedInfoSchema) HasTemporaryTable

func (ts *SessionExtendedInfoSchema) HasTemporaryTable() bool

HasTemporaryTable returns whether information schema has temporary table

func (*SessionExtendedInfoSchema) SchemaByID

func (ts *SessionExtendedInfoSchema) SchemaByID(id int64) (*model.DBInfo, bool)

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

func (*SessionExtendedInfoSchema) TableByID

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

TableByID implements InfoSchema.TableByID

func (*SessionExtendedInfoSchema) TableByName

func (ts *SessionExtendedInfoSchema) TableByName(ctx stdctx.Context, schema, table pmodel.CIStr) (table.Table, error)

TableByName implements InfoSchema.TableByName

func (*SessionExtendedInfoSchema) TableInfoByID

func (ts *SessionExtendedInfoSchema) TableInfoByID(id int64) (*model.TableInfo, bool)

TableInfoByID implements InfoSchema.TableInfoByID

func (*SessionExtendedInfoSchema) TableInfoByName

func (ts *SessionExtendedInfoSchema) TableInfoByName(schema, table pmodel.CIStr) (*model.TableInfo, error)

TableInfoByName implements InfoSchema.TableInfoByName

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 pmodel.CIStr) (exist bool)

RemoveTable remove a table

func (*SessionTables) SchemaByID

func (is *SessionTables) SchemaByID(id int64) (*model.DBInfo, bool)

SchemaByID get a table's schema from the schema ID.

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(ctx stdctx.Context, schema, table pmodel.CIStr) (table.Table, bool)

TableByName get table by name

func (*SessionTables) TableExists

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

TableExists check if table with the name exists

type Sieve

type Sieve[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Sieve is an efficient turn-Key eviction algorithm for web caches. See blog post https://cachemon.github.io/SIEVE-website/blog/2023/12/17/sieve-is-simpler-than-lru/ and also the academic paper "SIEVE is simpler than LRU"

func (*Sieve[K, V]) Capacity

func (s *Sieve[K, V]) Capacity() uint64

func (*Sieve[K, V]) Close

func (s *Sieve[K, V]) Close()

func (*Sieve[K, V]) Contains

func (s *Sieve[K, V]) Contains(key K) (ok bool)

func (*Sieve[K, V]) Get

func (s *Sieve[K, V]) Get(key K) (value V, ok bool)

func (*Sieve[K, V]) Len

func (s *Sieve[K, V]) Len() int

func (*Sieve[K, V]) Peek

func (s *Sieve[K, V]) Peek(key K) (value V, ok bool)

func (*Sieve[K, V]) Purge

func (s *Sieve[K, V]) Purge()

func (*Sieve[K, V]) Remove

func (s *Sieve[K, V]) Remove(key K) (ok bool)

func (*Sieve[K, V]) Set

func (s *Sieve[K, V]) Set(key K, value V)

func (*Sieve[K, V]) SetCapacity

func (s *Sieve[K, V]) SetCapacity(capacity uint64)

func (*Sieve[K, V]) SetCapacityAndWaitEvict

func (s *Sieve[K, V]) SetCapacityAndWaitEvict(capacity uint64)

func (*Sieve[K, V]) SetStatusHook

func (s *Sieve[K, V]) SetStatusHook(hook sieveStatusHook)

func (*Sieve[K, V]) Size

func (s *Sieve[K, V]) Size() uint64

type TableItem

type TableItem struct {
	DBName    pmodel.CIStr
	TableName pmodel.CIStr
}

TableItem is exported from tableItem.

type VirtualTable

type VirtualTable struct{}

VirtualTable is a dummy table.Table implementation.

func (*VirtualTable) AddRecord

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

AddRecord implements table.Table AddRecord interface.

func (*VirtualTable) 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) DeletableIndices

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

DeletableIndices implements table.Table DeletableIndices 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 table.MutateContext, txn kv.Transaction, h kv.Handle, r []types.Datum, opts ...table.RemoveRecordOption) 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 table.MutateContext, txn kv.Transaction, h kv.Handle, oldData, newData []types.Datum, touched []bool, opts ...table.UpdateRecordOption) 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.

func (*VirtualTable) WritableConstraint

func (vt *VirtualTable) WritableConstraint() []*table.Constraint

WritableConstraint implements table.Table WritableConstraint interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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