Documentation ¶
Index ¶
- Constants
- Variables
- func AllocHandle(ctx context.Context, sctx sessionctx.Context, t table.Table) (kv.Handle, error)
- func BuildFieldTypesForIndexColumns(idxInfo *model.IndexInfo, tblInfo *model.TableInfo) []*types.FieldType
- func BuildPartitionTableScanFromInfos(tableInfo *model.TableInfo, columnInfos []*model.ColumnInfo, fastScan bool) *tipb.PartitionTableScan
- func BuildRowcodecColInfoForIndexColumns(idxInfo *model.IndexInfo, tblInfo *model.TableInfo) []rowcodec.ColInfo
- func BuildTableScanFromInfos(tableInfo *model.TableInfo, columnInfos []*model.ColumnInfo) *tipb.TableScan
- func CanSkip(info *model.TableInfo, col *table.Column, value *types.Datum) bool
- func CheckDataConsistency(txn kv.Transaction, sessVars *variable.SessionVars, t *TableCommon, ...) error
- func ClearAddRecordCtx(ctx sessionctx.Context)
- func CompareIndexAndVal(sctx *stmtctx.StatementContext, rowVal types.Datum, idxVal types.Datum, ...) (int, error)
- func ConvertDatumToTailSpaceCount(datum *types.Datum, col *model.ColumnInfo)
- func DecodeRawRowData(ctx sessionctx.Context, meta *model.TableInfo, h kv.Handle, ...) ([]types.Datum, map[int64]types.Datum, error)
- func FetchDuplicatedHandle(ctx context.Context, key kv.Key, distinct bool, txn kv.Transaction, ...) (foundKey bool, dupHandle kv.Handle, err error)
- func FindChangingCol(cols []*table.Column, idxInfo *model.IndexInfo) *table.Column
- func FindIndexByColName(t table.Table, name string) table.Index
- func FindPartitionByName(meta *model.TableInfo, parName string) (int64, error)
- func FindPrimaryIndex(tblInfo *model.TableInfo) *model.IndexInfo
- func GenTempIdxKeyByState(indexInfo *model.IndexInfo, indexKey kv.Key) (key, tempKey kv.Key, tempKeyVer byte)
- func GetChangingColVal(ctx sessionctx.Context, cols []*table.Column, col *table.Column, ...) (_ types.Datum, isDefaultVal bool, err error)
- func GetColDefaultValue(ctx sessionctx.Context, col *table.Column, defaultVals []types.Datum) (colVal types.Datum, err error)
- func GetReorganizedPartitionedTable(t table.Table) (table.PartitionedTable, error)
- func GetWritableIndexByName(idxName string, t table.Table) table.Index
- func IsIndexWritable(idx table.Index) bool
- func IterRecords(t table.Table, ctx sessionctx.Context, cols []*table.Column, ...) error
- func MockTableFromMeta(tblInfo *model.TableInfo) table.Table
- func NeedRestoredData(idxCols []*model.IndexColumn, colInfos []*model.ColumnInfo) bool
- func NewIndex(physicalID int64, tblInfo *model.TableInfo, indexInfo *model.IndexInfo) table.Index
- func NewListPartitionLocationHelper() *listPartitionLocationHelper
- func NewPartitionTableWithGivenSets(tbl table.PartitionedTable, partitions map[int64]struct{}) table.PartitionedTable
- func NewStateRemote(exec sqlExec) *stateRemoteHandle
- func OverflowShardBits(recordID int64, shardRowIDBits uint64, typeBitsLength uint64, ...) bool
- func PartitionRecordKey(pid int64, handle int64) kv.Key
- func PrimaryPrefixColumnIDs(tbl *model.TableInfo) (prefixCols []int64)
- func RowWithCols(t table.Table, ctx sessionctx.Context, h kv.Handle, cols []*table.Column) ([]types.Datum, error)
- func SetAddRecordCtx(ctx sessionctx.Context, r *CommonAddRecordCtx)
- func SetPBColumnsDefaultValue(ctx sessionctx.Context, pbColumns []*tipb.ColumnInfo, ...) error
- func TableFromMeta(allocs autoid.Allocators, tblInfo *model.TableInfo) (table.Table, error)
- func TempTableFromMeta(tblInfo *model.TableInfo) tableutil.TempTable
- func TryAppendCommonHandleRowcodecColInfos(colInfo []rowcodec.ColInfo, tblInfo *model.TableInfo) []rowcodec.ColInfo
- func TryGetCommonPkColumnIds(tbl *model.TableInfo) []int64
- func TryGetCommonPkColumns(tbl table.Table) []*table.Column
- func TryGetHandleRestoredDataWrapper(tblInfo *model.TableInfo, row []types.Datum, rowMap map[int64]types.Datum, ...) []types.Datum
- func TryTruncateRestoredData(datum *types.Datum, pkCol *model.ColumnInfo, pkIdxCol *model.IndexColumn, ...)
- type CachedTableLockType
- type CommonAddRecordCtx
- type ForKeyPruning
- type ForListColumnPruning
- func (lp *ForListColumnPruning) LocatePartition(sc *stmtctx.StatementContext, v types.Datum) (ListPartitionLocation, error)
- func (lp *ForListColumnPruning) LocateRanges(sc *stmtctx.StatementContext, r *ranger.Range) ([]ListPartitionLocation, error)
- func (lp *ForListColumnPruning) RebuildPartitionValueMapAndSorted(p *parser.Parser, defs []model.PartitionDefinition) error
- type ForListPruning
- type ForRangeColumnsPruning
- type ForRangePruning
- type ListPartitionGroup
- type ListPartitionLocation
- type PartitionExpr
- type StateRemote
- type TableCommon
- func (t *TableCommon) AddRecord(sctx sessionctx.Context, r []types.Datum, opts ...table.AddRecordOption) (recordID kv.Handle, err error)
- func (t *TableCommon) Allocators(ctx sessionctx.Context) autoid.Allocators
- func (t *TableCommon) Cols() []*table.Column
- func (t *TableCommon) DeletableCols() []*table.Column
- func (t *TableCommon) FullHiddenColsAndVisibleCols() []*table.Column
- func (t *TableCommon) GetPartitionedTable() table.PartitionedTable
- func (t *TableCommon) GetPhysicalID() int64
- func (t *TableCommon) GetSequenceCommon() *sequenceCommon
- func (t *TableCommon) GetSequenceID() int64
- func (t *TableCommon) GetSequenceNextVal(ctx interface{}, dbName, seqName string) (nextVal int64, err error)
- func (t *TableCommon) HiddenCols() []*table.Column
- func (t *TableCommon) IndexPrefix() kv.Key
- func (t *TableCommon) Indices() []table.Index
- func (t *TableCommon) Meta() *model.TableInfo
- func (t *TableCommon) RecordKey(h kv.Handle) kv.Key
- func (t *TableCommon) RecordPrefix() kv.Key
- func (t *TableCommon) RemoveRecord(ctx sessionctx.Context, h kv.Handle, r []types.Datum) error
- func (t *TableCommon) SetSequenceVal(ctx interface{}, newVal int64, dbName, seqName string) (int64, bool, error)
- func (t *TableCommon) Type() table.Type
- func (t *TableCommon) UpdateRecord(ctx context.Context, sctx sessionctx.Context, h kv.Handle, ...) error
- func (t *TableCommon) VisibleCols() []*table.Column
- func (t *TableCommon) WritableCols() []*table.Column
- type TemporaryTable
- func (t *TemporaryTable) GetAutoIDAllocator() autoid.Allocator
- func (t *TemporaryTable) GetMeta() *model.TableInfo
- func (t *TemporaryTable) GetModified() bool
- func (t *TemporaryTable) GetSize() int64
- func (t *TemporaryTable) GetStats() interface{}
- func (t *TemporaryTable) SetModified(modified bool)
- func (t *TemporaryTable) SetSize(v int64)
Constants ¶
const ( // TempIndexKeyTypeNone means the key is not a temporary index key. TempIndexKeyTypeNone byte = 0 // TempIndexKeyTypeDelete indicates this value is written in the delete-only stage. TempIndexKeyTypeDelete byte = 'd' // TempIndexKeyTypeBackfill indicates this value is written in the backfill stage. TempIndexKeyTypeBackfill byte = 'b' // TempIndexKeyTypeMerge indicates this value is written in the merge stage. TempIndexKeyTypeMerge byte = 'm' )
Variables ¶
var ( // ErrInconsistentRowValue is the error when values in a row insertion does not match the expected ones. ErrInconsistentRowValue = dbterror.ClassTable.NewStd(errno.ErrInconsistentRowValue) // ErrInconsistentHandle is the error when the handle in the row/index insertions does not match. ErrInconsistentHandle = dbterror.ClassTable.NewStd(errno.ErrInconsistentHandle) // ErrInconsistentIndexedValue is the error when decoded values from the index mutation cannot match row value ErrInconsistentIndexedValue = dbterror.ClassTable.NewStd(errno.ErrInconsistentIndexedValue) )
var TestMockRenewLeaseABA2 chan struct{}
TestMockRenewLeaseABA2 is used by test function TestRenewLeaseABAFailPoint.
Functions ¶
func AllocHandle ¶
AllocHandle allocate a new handle. A statement could reserve some ID in the statement context, try those ones first.
func BuildFieldTypesForIndexColumns ¶
func BuildFieldTypesForIndexColumns(idxInfo *model.IndexInfo, tblInfo *model.TableInfo) []*types.FieldType
BuildFieldTypesForIndexColumns builds the index columns field types.
func BuildPartitionTableScanFromInfos ¶
func BuildPartitionTableScanFromInfos(tableInfo *model.TableInfo, columnInfos []*model.ColumnInfo, fastScan bool) *tipb.PartitionTableScan
BuildPartitionTableScanFromInfos build tipb.PartitonTableScan with *model.TableInfo and *model.ColumnInfo.
func BuildRowcodecColInfoForIndexColumns ¶
func BuildRowcodecColInfoForIndexColumns(idxInfo *model.IndexInfo, tblInfo *model.TableInfo) []rowcodec.ColInfo
BuildRowcodecColInfoForIndexColumns builds []rowcodec.ColInfo for the given index. The result can be used for decoding index key-values.
func BuildTableScanFromInfos ¶
func BuildTableScanFromInfos(tableInfo *model.TableInfo, columnInfos []*model.ColumnInfo) *tipb.TableScan
BuildTableScanFromInfos build tipb.TableScan with *model.TableInfo and *model.ColumnInfo.
func CanSkip ¶
CanSkip is for these cases, we can skip the columns in encoded row: 1. the column is included in primary key; 2. the column's default value is null, and the value equals to that but has no origin default; 3. the column is virtual generated.
func CheckDataConsistency ¶
func CheckDataConsistency( txn kv.Transaction, sessVars *variable.SessionVars, t *TableCommon, rowToInsert, rowToRemove []types.Datum, memBuffer kv.MemBuffer, sh kv.StagingHandle, ) error
CheckDataConsistency checks whether the given set of mutations corresponding to a single row is consistent. Namely, assume the database is consistent before, applying the mutations shouldn't break the consistency. It aims at reducing bugs that will corrupt data, and preventing mistakes from spreading if possible.
3 conditions are checked: (1) row.value is consistent with input data (2) the handle is consistent in row and index insertions (3) the keys of the indices are consistent with the values of rows
The check doesn't work and just returns nil when: (1) the table is partitioned (2) new collation is enabled and restored data is needed
The check is performed on almost every write. Its performance matters. Let M = the number of mutations, C = the number of columns in the table, I = the sum of the number of columns in all indices, The time complexity is O(M * C + I) The space complexity is O(M + C + I)
func ClearAddRecordCtx ¶
func ClearAddRecordCtx(ctx sessionctx.Context)
ClearAddRecordCtx remove `CommonAddRecordCtx` from session context
func CompareIndexAndVal ¶
func CompareIndexAndVal(sctx *stmtctx.StatementContext, rowVal types.Datum, idxVal types.Datum, collator collate.Collator, cmpMVIndex bool) (int, error)
CompareIndexAndVal compare index valued and row value.
func ConvertDatumToTailSpaceCount ¶
func ConvertDatumToTailSpaceCount(datum *types.Datum, col *model.ColumnInfo)
ConvertDatumToTailSpaceCount converts a string datum to an int datum that represents the tail space count.
func DecodeRawRowData ¶
func DecodeRawRowData(ctx sessionctx.Context, meta *model.TableInfo, h kv.Handle, cols []*table.Column, value []byte) ([]types.Datum, map[int64]types.Datum, error)
DecodeRawRowData decodes raw row data into a datum slice and a (columnID:columnValue) map.
func FetchDuplicatedHandle ¶
func FetchDuplicatedHandle(ctx context.Context, key kv.Key, distinct bool, txn kv.Transaction, tableID int64, isCommon bool) (foundKey bool, dupHandle kv.Handle, err error)
FetchDuplicatedHandle is used to find the duplicated row's handle for a given unique index key.
func FindChangingCol ¶
FindChangingCol finds the changing column in idxInfo.
func FindIndexByColName ¶
FindIndexByColName returns a public table index containing only one column named `name`.
func FindPartitionByName ¶
FindPartitionByName finds partition in table meta by name.
func FindPrimaryIndex ¶
FindPrimaryIndex uses to find primary index in tableInfo.
func GenTempIdxKeyByState ¶
func GenTempIdxKeyByState(indexInfo *model.IndexInfo, indexKey kv.Key) (key, tempKey kv.Key, tempKeyVer byte)
GenTempIdxKeyByState is used to get the key version and the temporary key. The tempKeyVer means the temp index key/value version.
func GetChangingColVal ¶
func GetChangingColVal(ctx sessionctx.Context, cols []*table.Column, col *table.Column, rowMap map[int64]types.Datum, defaultVals []types.Datum) (_ types.Datum, isDefaultVal bool, err error)
GetChangingColVal gets the changing column value when executing "modify/change column" statement. For statement like update-where, it will fetch the old row out and insert it into kv again. Since update statement can see the writable columns, it is responsible for the casting relative column / get the fault value here. old row : a-b-[nil] new row : a-b-[a'/default] Thus the writable new row is corresponding to Write-Only constraints.
func GetColDefaultValue ¶
func GetColDefaultValue(ctx sessionctx.Context, col *table.Column, defaultVals []types.Datum) ( colVal types.Datum, err error)
GetColDefaultValue gets a column default value. The defaultVals is used to avoid calculating the default value multiple times.
func GetReorganizedPartitionedTable ¶
func GetReorganizedPartitionedTable(t table.Table) (table.PartitionedTable, error)
GetReorganizedPartitionedTable returns the same table but only with the AddingDefinitions used.
func GetWritableIndexByName ¶
GetWritableIndexByName gets the index meta from the table by the index name.
func IsIndexWritable ¶
IsIndexWritable check whether the index is writable.
func IterRecords ¶
func IterRecords(t table.Table, ctx sessionctx.Context, cols []*table.Column, fn table.RecordIterFunc) error
IterRecords iterates records in the table and calls fn.
func MockTableFromMeta ¶
MockTableFromMeta only serves for test.
func NeedRestoredData ¶
func NeedRestoredData(idxCols []*model.IndexColumn, colInfos []*model.ColumnInfo) bool
NeedRestoredData checks whether the index columns needs restored data.
func NewListPartitionLocationHelper ¶
func NewListPartitionLocationHelper() *listPartitionLocationHelper
NewListPartitionLocationHelper returns a new listPartitionLocationHelper.
func NewPartitionTableWithGivenSets ¶
func NewPartitionTableWithGivenSets(tbl table.PartitionedTable, partitions map[int64]struct{}) table.PartitionedTable
NewPartitionTableWithGivenSets creates a new partition table from a partition table.
func NewStateRemote ¶
func NewStateRemote(exec sqlExec) *stateRemoteHandle
NewStateRemote creates a StateRemote object.
func OverflowShardBits ¶
func OverflowShardBits(recordID int64, shardRowIDBits uint64, typeBitsLength uint64, reservedSignBit bool) bool
OverflowShardBits checks whether the recordID overflow `1<<(typeBitsLength-shardRowIDBits-1) -1`.
func PartitionRecordKey ¶
PartitionRecordKey is exported for test.
func PrimaryPrefixColumnIDs ¶
PrimaryPrefixColumnIDs get prefix column ids in primary key.
func RowWithCols ¶
func RowWithCols(t table.Table, ctx sessionctx.Context, h kv.Handle, cols []*table.Column) ([]types.Datum, error)
RowWithCols is used to get the corresponding column datum values with the given handle.
func SetAddRecordCtx ¶
func SetAddRecordCtx(ctx sessionctx.Context, r *CommonAddRecordCtx)
SetAddRecordCtx set a CommonAddRecordCtx to session context
func SetPBColumnsDefaultValue ¶
func SetPBColumnsDefaultValue(ctx sessionctx.Context, pbColumns []*tipb.ColumnInfo, columns []*model.ColumnInfo) error
SetPBColumnsDefaultValue sets the default values of tipb.ColumnInfo.
func TableFromMeta ¶
TableFromMeta creates a Table instance from model.TableInfo.
func TempTableFromMeta ¶
TempTableFromMeta builds a TempTable from model.TableInfo.
func TryAppendCommonHandleRowcodecColInfos ¶
func TryAppendCommonHandleRowcodecColInfos(colInfo []rowcodec.ColInfo, tblInfo *model.TableInfo) []rowcodec.ColInfo
TryAppendCommonHandleRowcodecColInfos tries to append common handle columns to `colInfo`.
func TryGetCommonPkColumnIds ¶
TryGetCommonPkColumnIds get the IDs of primary key column if the table has common handle.
func TryGetCommonPkColumns ¶
TryGetCommonPkColumns get the primary key columns if the table has common handle.
func TryGetHandleRestoredDataWrapper ¶
func TryGetHandleRestoredDataWrapper(tblInfo *model.TableInfo, row []types.Datum, rowMap map[int64]types.Datum, idx *model.IndexInfo) []types.Datum
TryGetHandleRestoredDataWrapper tries to get the restored data for handle if needed. The argument can be a slice or a map.
func TryTruncateRestoredData ¶
func TryTruncateRestoredData(datum *types.Datum, pkCol *model.ColumnInfo, pkIdxCol *model.IndexColumn, idx *model.IndexInfo)
TryTruncateRestoredData tries to truncate index values. Says that primary key(a (8)), For index t(a), don't truncate the value. For index t(a(9)), truncate to a(9). For index t(a(7)), truncate to a(8).
Types ¶
type CachedTableLockType ¶
type CachedTableLockType int
CachedTableLockType define the lock type for cached table
const ( // CachedTableLockNone means there is no lock. CachedTableLockNone CachedTableLockType = iota // CachedTableLockRead is the READ lock type. CachedTableLockRead // CachedTableLockIntend is the write INTEND, it exists when the changing READ to WRITE, and the READ lock lease is not expired.. CachedTableLockIntend // CachedTableLockWrite is the WRITE lock type. CachedTableLockWrite )
func (CachedTableLockType) String ¶
func (l CachedTableLockType) String() string
type CommonAddRecordCtx ¶
type CommonAddRecordCtx struct {
// contains filtered or unexported fields
}
CommonAddRecordCtx is used in `AddRecord` to avoid memory malloc for some temp slices. This is useful in lightning parse row data to key-values pairs. This can gain upto 5% performance improvement in lightning's local mode.
func NewCommonAddRecordCtx ¶
func NewCommonAddRecordCtx(size int) *CommonAddRecordCtx
NewCommonAddRecordCtx create a context used for `AddRecord`
type ForKeyPruning ¶
type ForKeyPruning struct {
KeyPartCols []*expression.Column
}
ForKeyPruning is used for key partition pruning.
func (*ForKeyPruning) LocateKeyPartition ¶
LocateKeyPartition is the common interface used to locate the destination partition
type ForListColumnPruning ¶
type ForListColumnPruning struct { ExprCol *expression.Column // contains filtered or unexported fields }
ForListColumnPruning is used for list columns partition pruning.
func (*ForListColumnPruning) LocatePartition ¶
func (lp *ForListColumnPruning) LocatePartition(sc *stmtctx.StatementContext, v types.Datum) (ListPartitionLocation, error)
LocatePartition locates partition by the column value
func (*ForListColumnPruning) LocateRanges ¶
func (lp *ForListColumnPruning) LocateRanges(sc *stmtctx.StatementContext, r *ranger.Range) ([]ListPartitionLocation, error)
LocateRanges locates partition ranges by the column range
func (*ForListColumnPruning) RebuildPartitionValueMapAndSorted ¶
func (lp *ForListColumnPruning) RebuildPartitionValueMapAndSorted(p *parser.Parser, defs []model.PartitionDefinition) error
RebuildPartitionValueMapAndSorted rebuilds list columns partition value map for the specified column.
type ForListPruning ¶
type ForListPruning struct { // LocateExpr uses to locate list partition by row. LocateExpr expression.Expression // PruneExpr uses to prune list partition in partition pruner. PruneExpr expression.Expression // PruneExprCols is the columns of PruneExpr, it has removed the duplicate columns. PruneExprCols []*expression.Column // For list columns partition pruning ColPrunes []*ForListColumnPruning // contains filtered or unexported fields }
ForListPruning is used for list partition pruning.
func (*ForListPruning) Clone ¶
func (lp *ForListPruning) Clone() *ForListPruning
Clone a copy of ForListPruning
func (*ForListPruning) LocatePartition ¶
func (lp *ForListPruning) LocatePartition(value int64, isNull bool) int
LocatePartition locates partition by the column value
type ForRangeColumnsPruning ¶
type ForRangeColumnsPruning struct { // LessThan contains expressions for [Partition][column]. // If Maxvalue, then nil LessThan [][]*expression.Expression }
ForRangeColumnsPruning is used for range partition pruning.
type ForRangePruning ¶
ForRangePruning is used for range partition pruning.
type ListPartitionGroup ¶
type ListPartitionGroup struct { // Such as: list columns (a,b) (partition p0 values in ((1,5),(1,6))); // For the column a which value is 1, the ListPartitionGroup is: // ListPartitionGroup { // PartIdx: 0, // 0 is the partition p0 index in all partitions. // GroupIdxs: []int{0,1}, // p0 has 2 value group: (1,5) and (1,6), and they both contain the column a where value is 1; // } // the value of GroupIdxs `0,1` is the index of the value group that contain the column a which value is 1. PartIdx int GroupIdxs []int }
ListPartitionGroup indicate the group index of the column value in a partition.
type ListPartitionLocation ¶
type ListPartitionLocation []ListPartitionGroup
ListPartitionLocation indicate the partition location for the column value in list columns partition. Here is an example: Suppose the list columns partition is: list columns (a,b) (partition p0 values in ((1,5),(1,6)), partition p1 values in ((1,7),(9,9))); How to express the location of the column a which value is 1? For the column a which value is 1, both partition p0 and p1 contain the column a which value is 1. In partition p0, both value group0 (1,5) and group1 (1,6) are contain the column a which value is 1. In partition p1, value group0 (1,7) contains the column a which value is 1. So, the ListPartitionLocation of column a which value is 1 is:
[]ListPartitionGroup{ { PartIdx: 0, // `0` is the partition p0 index in all partitions. GroupIdxs: []int{0, 1} // `0,1` is the index of the value group0, group1. }, { PartIdx: 1, // `1` is the partition p1 index in all partitions. GroupIdxs: []int{0} // `0` is the index of the value group0. }, }
func (ListPartitionLocation) IsEmpty ¶
func (ps ListPartitionLocation) IsEmpty() bool
IsEmpty returns true if the ListPartitionLocation is empty.
type PartitionExpr ¶
type PartitionExpr struct { // UpperBounds: (x < y1); (x < y2); (x < y3), used by locatePartition. UpperBounds []expression.Expression // OrigExpr is the partition expression ast used in point get. OrigExpr ast.ExprNode // Expr is the hash partition expression. Expr expression.Expression // Used in the key partition *ForKeyPruning // Used in the range pruning process. *ForRangePruning // Used in the range column pruning process. *ForRangeColumnsPruning // ColOffset is the offsets of partition columns. ColumnOffset []int *ForListPruning }
PartitionExpr is the partition definition expressions.
func (*PartitionExpr) GetPartColumnsForKeyPartition ¶
func (pe *PartitionExpr) GetPartColumnsForKeyPartition(columns []*expression.Column) ([]*expression.Column, []int)
GetPartColumnsForKeyPartition is used to get partition columns for key partition table
func (*PartitionExpr) LocateKeyPartitionWithSPC ¶
func (pe *PartitionExpr) LocateKeyPartitionWithSPC(pi *model.PartitionInfo, r []types.Datum) (int, error)
LocateKeyPartitionWithSPC is used to locate the destination partition for key partition table has single partition column(SPC). It's called in FastPlan process.
type StateRemote ¶
type StateRemote interface { // Load obtain the corresponding lock type and lease value according to the tableID Load(ctx context.Context, tid int64) (CachedTableLockType, uint64, error) // LockForRead try to add a read lock to the table with the specified tableID. // If this operation succeed, according to the protocol, the TiKV data will not be // modified until the lease expire. It's safe for the caller to load the table data, // cache and use the data. LockForRead(ctx context.Context, tid int64, lease uint64) (bool, error) // LockForWrite try to add a write lock to the table with the specified tableID LockForWrite(ctx context.Context, tid int64, leaseDuration time.Duration) (uint64, error) // RenewReadLease attempt to renew the read lock lease on the table with the specified tableID RenewReadLease(ctx context.Context, tid int64, oldLocalLease, newValue uint64) (uint64, error) // RenewWriteLease attempt to renew the write lock lease on the table with the specified tableID RenewWriteLease(ctx context.Context, tid int64, newTs uint64) (bool, error) }
StateRemote is the interface to control the remote state of the cached table's lock meta information. IMPORTANT: It's not thread-safe, the caller should be aware of that!
type TableCommon ¶
type TableCommon struct { Columns []*table.Column PublicColumns []*table.Column VisibleColumns []*table.Column HiddenColumns []*table.Column WritableColumns []*table.Column FullHiddenColsAndVisibleColumns []*table.Column // contains filtered or unexported fields }
TableCommon is shared by both Table and partition.
func (*TableCommon) AddRecord ¶
func (t *TableCommon) AddRecord(sctx sessionctx.Context, r []types.Datum, opts ...table.AddRecordOption) (recordID kv.Handle, err error)
AddRecord implements table.Table AddRecord interface.
func (*TableCommon) Allocators ¶
func (t *TableCommon) Allocators(ctx sessionctx.Context) autoid.Allocators
Allocators implements table.Table Allocators interface.
func (*TableCommon) Cols ¶
func (t *TableCommon) Cols() []*table.Column
Cols implements table.Table Cols interface.
func (*TableCommon) DeletableCols ¶
func (t *TableCommon) DeletableCols() []*table.Column
DeletableCols implements table DeletableCols interface.
func (*TableCommon) FullHiddenColsAndVisibleCols ¶
func (t *TableCommon) FullHiddenColsAndVisibleCols() []*table.Column
FullHiddenColsAndVisibleCols implements table FullHiddenColsAndVisibleCols interface.
func (*TableCommon) GetPartitionedTable ¶
func (t *TableCommon) GetPartitionedTable() table.PartitionedTable
GetPartitionedTable implements table.Table GetPhysicalID interface.
func (*TableCommon) GetPhysicalID ¶
func (t *TableCommon) GetPhysicalID() int64
GetPhysicalID implements table.Table GetPhysicalID interface.
func (*TableCommon) GetSequenceCommon ¶
func (t *TableCommon) GetSequenceCommon() *sequenceCommon
GetSequenceCommon is used in test to get sequenceCommon.
func (*TableCommon) GetSequenceID ¶
func (t *TableCommon) GetSequenceID() int64
GetSequenceID implements util.SequenceTable GetSequenceID interface.
func (*TableCommon) GetSequenceNextVal ¶
func (t *TableCommon) GetSequenceNextVal(ctx interface{}, dbName, seqName string) (nextVal int64, err error)
GetSequenceNextVal implements util.SequenceTable GetSequenceNextVal interface. Caching the sequence value in table, we can easily be notified with the cache empty, and write the binlogInfo in table level rather than in allocator.
func (*TableCommon) HiddenCols ¶
func (t *TableCommon) HiddenCols() []*table.Column
HiddenCols implements table.Table HiddenCols interface.
func (*TableCommon) IndexPrefix ¶
func (t *TableCommon) IndexPrefix() kv.Key
IndexPrefix implements table.Table interface.
func (*TableCommon) Indices ¶
func (t *TableCommon) Indices() []table.Index
Indices implements table.Table Indices interface.
func (*TableCommon) Meta ¶
func (t *TableCommon) Meta() *model.TableInfo
Meta implements table.Table Meta interface.
func (*TableCommon) RecordKey ¶
func (t *TableCommon) RecordKey(h kv.Handle) kv.Key
RecordKey implements table.Table interface.
func (*TableCommon) RecordPrefix ¶
func (t *TableCommon) RecordPrefix() kv.Key
RecordPrefix implements table.Table interface.
func (*TableCommon) RemoveRecord ¶
func (t *TableCommon) RemoveRecord(ctx sessionctx.Context, h kv.Handle, r []types.Datum) error
RemoveRecord implements table.Table RemoveRecord interface.
func (*TableCommon) SetSequenceVal ¶
func (t *TableCommon) SetSequenceVal(ctx interface{}, newVal int64, dbName, seqName string) (int64, bool, error)
SetSequenceVal implements util.SequenceTable SetSequenceVal interface. The returned bool indicates the newVal is already under the base.
func (*TableCommon) Type ¶
func (t *TableCommon) Type() table.Type
Type implements table.Table Type interface.
func (*TableCommon) UpdateRecord ¶
func (t *TableCommon) UpdateRecord(ctx context.Context, sctx sessionctx.Context, h kv.Handle, oldData, newData []types.Datum, touched []bool) error
UpdateRecord implements table.Table UpdateRecord interface. `touched` means which columns are really modified, used for secondary indices. Length of `oldData` and `newData` equals to length of `t.WritableCols()`.
func (*TableCommon) VisibleCols ¶
func (t *TableCommon) VisibleCols() []*table.Column
VisibleCols implements table.Table VisibleCols interface.
func (*TableCommon) WritableCols ¶
func (t *TableCommon) WritableCols() []*table.Column
WritableCols implements table WritableCols interface.
type TemporaryTable ¶
type TemporaryTable struct {
// contains filtered or unexported fields
}
TemporaryTable is used to store transaction-specific or session-specific information for global / local temporary tables. For example, stats and autoID should have their own copies of data, instead of being shared by all sessions.
func (*TemporaryTable) GetAutoIDAllocator ¶
func (t *TemporaryTable) GetAutoIDAllocator() autoid.Allocator
GetAutoIDAllocator is implemented from TempTable.GetAutoIDAllocator.
func (*TemporaryTable) GetMeta ¶
func (t *TemporaryTable) GetMeta() *model.TableInfo
GetMeta gets the table meta.
func (*TemporaryTable) GetModified ¶
func (t *TemporaryTable) GetModified() bool
GetModified is implemented from TempTable.GetModified.
func (*TemporaryTable) GetSize ¶
func (t *TemporaryTable) GetSize() int64
GetSize gets the table size.
func (*TemporaryTable) GetStats ¶
func (t *TemporaryTable) GetStats() interface{}
GetStats is implemented from TempTable.GetStats.
func (*TemporaryTable) SetModified ¶
func (t *TemporaryTable) SetModified(modified bool)
SetModified is implemented from TempTable.SetModified.
func (*TemporaryTable) SetSize ¶
func (t *TemporaryTable) SetSize(v int64)
SetSize sets the table size.