tidb: github.com/pingcap/tidb/util/admin Index | Files

package admin

import "github.com/pingcap/tidb/util/admin"

Index

Package Files

admin.go

Constants

const (
    // TblCntGreater means that the number of table rows is more than the number of index rows.
    TblCntGreater byte = 1
    // IdxCntGreater means that the number of index rows is more than the number of table rows.
    IdxCntGreater byte = 2
)

Count greater Types

const DefNumHistoryJobs = 10

DefNumHistoryJobs is default value of the default number of history job

const MaxHistoryJobs = 10

MaxHistoryJobs is exported for testing.

Variables

var (
    // ErrDataInConsistent indicate that meets inconsistent data.
    ErrDataInConsistent = terror.ClassAdmin.New(codeDataNotEqual, "data isn't equal")

    // ErrDDLJobNotFound indicates the job id was not found.
    ErrDDLJobNotFound = terror.ClassAdmin.New(codeDDLJobNotFound, "DDL Job:%v not found")
    // ErrCancelFinishedDDLJob returns when cancel a finished ddl job.
    ErrCancelFinishedDDLJob = terror.ClassAdmin.New(codeCancelFinishedJob, "This job:%v is finished, so can't be cancelled")
    // ErrCannotCancelDDLJob returns when cancel a almost finished ddl job, because cancel in now may cause data inconsistency.
    ErrCannotCancelDDLJob = terror.ClassAdmin.New(codeCannotCancelDDLJob, "This job:%v is almost finished, can't be cancelled now")
)

func CancelJobs Uses

func CancelJobs(txn kv.Transaction, ids []int64) ([]error, error)

CancelJobs cancels the DDL jobs.

func CheckIndicesCount Uses

func CheckIndicesCount(ctx sessionctx.Context, dbName, tableName string, indices []string) (byte, int, error)

CheckIndicesCount compares indices count with table count. It returns the count greater type, the index offset and an error. It returns nil if the count from the index is equal to the count from the table columns, otherwise it returns an error and the corresponding index's offset.

func CheckRecordAndIndex Uses

func CheckRecordAndIndex(sessCtx sessionctx.Context, txn kv.Transaction, t table.Table, idx table.Index, genExprs map[model.TableColumnID]expression.Expression) error

CheckRecordAndIndex is exported for testing.

func CompareIndexData Uses

func CompareIndexData(sessCtx sessionctx.Context, txn kv.Transaction, t table.Table, idx table.Index, genExprs map[model.TableColumnID]expression.Expression) error

CompareIndexData compares index data one by one. It returns nil if the data from the index is equal to the data from the table columns, otherwise it returns an error with a different set of records. genExprs is use to calculate the virtual generate column.

func CompareTableRecord Uses

func CompareTableRecord(sessCtx sessionctx.Context, txn kv.Transaction, t table.Table, data []*RecordData, exact bool) error

CompareTableRecord compares data and the corresponding table data one by one. It returns nil if data is equal to the data that scans from table, otherwise it returns an error with a different set of records. If exact is false, only compares handle.

func GetDDLJobs Uses

func GetDDLJobs(txn kv.Transaction) ([]*model.Job, error)

GetDDLJobs get all DDL jobs and sorts jobs by job.ID.

func GetHistoryDDLJobs Uses

func GetHistoryDDLJobs(txn kv.Transaction, maxNumJobs int) ([]*model.Job, error)

GetHistoryDDLJobs returns the DDL history jobs and an error. The maximum count of history jobs is num.

func IsJobRollbackable Uses

func IsJobRollbackable(job *model.Job) bool

IsJobRollbackable checks whether the job can be rollback.

type DDLInfo Uses

type DDLInfo struct {
    SchemaVer   int64
    ReorgHandle int64        // It's only used for DDL information.
    Jobs        []*model.Job // It's the currently running jobs.
}

DDLInfo is for DDL information.

func GetDDLInfo Uses

func GetDDLInfo(txn kv.Transaction) (*DDLInfo, error)

GetDDLInfo returns DDL information.

type RecordData Uses

type RecordData struct {
    Handle int64
    Values []types.Datum
}

RecordData is the record data composed of a handle and values.

func ScanIndexData Uses

func ScanIndexData(sc *stmtctx.StatementContext, txn kv.Transaction, kvIndex table.Index, startVals []types.Datum, limit int64) (
    []*RecordData, []types.Datum, error)

ScanIndexData scans the index handles and values in a limited number, according to the index information. It returns data and the next startVals until it doesn't have data, then returns data is nil and the next startVals is the values which can't get data. If startVals = nil and limit = -1, it returns the index data of the whole.

func ScanSnapshotTableRecord Uses

func ScanSnapshotTableRecord(sessCtx sessionctx.Context, store kv.Storage, ver kv.Version, t table.Table, startHandle, limit int64) (
    []*RecordData, int64, error)

ScanSnapshotTableRecord scans the ver version of the table data in a limited number. It returns data and the next startHandle until it doesn't have data, then returns data is nil and the next startHandle is the handle which can't get data. If startHandle = 0 and limit = -1, it returns the table data of the whole.

func ScanTableRecord Uses

func ScanTableRecord(sessCtx sessionctx.Context, retriever kv.Retriever, t table.Table, startHandle, limit int64) (
    []*RecordData, int64, error)

ScanTableRecord scans table row handles and column values in a limited number. It returns data and the next startHandle until it doesn't have data, then returns data is nil and the next startHandle is the handle which can't get data. If startHandle = 0 and limit = -1, it returns the table data of the whole.

Package admin imports 24 packages (graph) and is imported by 16 packages. Updated 2019-09-18. Refresh now. Tools for package owners.