tidb: github.com/pingcap/tidb/meta Index | Files | Directories

package meta

import "github.com/pingcap/tidb/meta"

Index

Package Files

meta.go

Variables

var (
    // ErrDBExists is the error for db exists.
    ErrDBExists = terror.ClassMeta.New(mysql.ErrDBCreateExists, mysql.MySQLErrName[mysql.ErrDBCreateExists])
    // ErrDBNotExists is the error for db not exists.
    ErrDBNotExists = terror.ClassMeta.New(mysql.ErrBadDB, mysql.MySQLErrName[mysql.ErrBadDB])
    // ErrTableExists is the error for table exists.
    ErrTableExists = terror.ClassMeta.New(mysql.ErrTableExists, mysql.MySQLErrName[mysql.ErrTableExists])
    // ErrTableNotExists is the error for table not exists.
    ErrTableNotExists = terror.ClassMeta.New(mysql.ErrNoSuchTable, mysql.MySQLErrName[mysql.ErrNoSuchTable])
)

func DDLJobHistoryKey Uses

func DDLJobHistoryKey(m *Meta, jobID int64) []byte

DDLJobHistoryKey is only used for testing.

type JobListKeyType Uses

type JobListKeyType []byte

JobListKeyType is a key type of the DDL job queue.

var (
    // DefaultJobListKey keeps all actions of DDL jobs except "add index".
    DefaultJobListKey JobListKeyType = mDDLJobListKey
    // AddIndexJobListKey only keeps the action of adding index.
    AddIndexJobListKey JobListKeyType = mDDLJobAddIdxList
)

type LastJobIterator Uses

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

LastJobIterator is the iterator for gets latest history.

func (*LastJobIterator) GetLastJobs Uses

func (i *LastJobIterator) GetLastJobs(num int, jobs []*model.Job) ([]*model.Job, error)

GetLastJobs gets last several jobs.

type Meta Uses

type Meta struct {
    StartTS uint64 // StartTS is the txn's start TS.
    // contains filtered or unexported fields
}

Meta is for handling meta information in a transaction.

func NewMeta Uses

func NewMeta(txn kv.Transaction, jobListKeys ...JobListKeyType) *Meta

NewMeta creates a Meta in transaction txn. If the current Meta needs to handle a job, jobListKey is the type of the job's list.

func NewSnapshotMeta Uses

func NewSnapshotMeta(snapshot kv.Snapshot) *Meta

NewSnapshotMeta creates a Meta with snapshot.

func (*Meta) AddHistoryDDLJob Uses

func (m *Meta) AddHistoryDDLJob(job *model.Job, updateRawArgs bool) error

AddHistoryDDLJob adds DDL job to history.

func (*Meta) CreateDatabase Uses

func (m *Meta) CreateDatabase(dbInfo *model.DBInfo) error

CreateDatabase creates a database with db info.

func (*Meta) CreateSequenceAndSetSeqValue Uses

func (m *Meta) CreateSequenceAndSetSeqValue(dbID int64, tableInfo *model.TableInfo, seqValue int64) error

CreateSequenceAndSetSeqValue creates sequence with tableInfo in database, and rebase the sequence seqValue.

func (*Meta) CreateTableAndSetAutoID Uses

func (m *Meta) CreateTableAndSetAutoID(dbID int64, tableInfo *model.TableInfo, autoIncID, autoRandID int64) error

CreateTableAndSetAutoID creates a table with tableInfo in database, and rebases the table autoID.

func (*Meta) CreateTableOrView Uses

func (m *Meta) CreateTableOrView(dbID int64, tableInfo *model.TableInfo) error

CreateTableOrView creates a table with tableInfo in database.

func (*Meta) DDLJobQueueLen Uses

func (m *Meta) DDLJobQueueLen(jobListKeys ...JobListKeyType) (int64, error)

DDLJobQueueLen returns the DDL job queue length. The length of jobListKeys can only be 1 or 0. If its length is 1, we need to replace m.jobListKey with jobListKeys[0]. Otherwise, we use m.jobListKey directly.

func (*Meta) DeQueueDDLJob Uses

func (m *Meta) DeQueueDDLJob() (*model.Job, error)

DeQueueDDLJob pops a DDL job from the list.

func (*Meta) DropDatabase Uses

func (m *Meta) DropDatabase(dbID int64) error

DropDatabase drops whole database.

func (*Meta) DropSequence Uses

func (m *Meta) DropSequence(dbID int64, tblID int64, delAutoID bool) error

DropSequence drops sequence in database. Sequence is made of table struct and kv value pair.

func (*Meta) DropTableOrView Uses

func (m *Meta) DropTableOrView(dbID int64, tblID int64, delAutoID bool) error

DropTableOrView drops table in database. If delAutoID is true, it will delete the auto_increment id key-value of the table. For rename table, we do not need to rename auto_increment id key-value.

func (*Meta) EnQueueDDLJob Uses

func (m *Meta) EnQueueDDLJob(job *model.Job, jobListKeys ...JobListKeyType) error

EnQueueDDLJob adds a DDL job to the list.

func (*Meta) FinishBootstrap Uses

func (m *Meta) FinishBootstrap(version int64) error

FinishBootstrap finishes bootstrap.

func (*Meta) GenAutoRandomID Uses

func (m *Meta) GenAutoRandomID(dbID, tableID, step int64) (int64, error)

GenAutoRandomID adds step to the auto shard ID of the table and returns the sum.

func (*Meta) GenAutoTableID Uses

func (m *Meta) GenAutoTableID(dbID, tableID, step int64) (int64, error)

GenAutoTableID adds step to the auto ID of the table and returns the sum.

func (*Meta) GenAutoTableIDKeyValue Uses

func (m *Meta) GenAutoTableIDKeyValue(dbID, tableID, autoID int64) (key, value []byte)

GenAutoTableIDKeyValue generates meta key by dbID, tableID and corresponding value by autoID.

func (*Meta) GenGlobalID Uses

func (m *Meta) GenGlobalID() (int64, error)

GenGlobalID generates next id globally.

func (*Meta) GenGlobalIDs Uses

func (m *Meta) GenGlobalIDs(n int) ([]int64, error)

GenGlobalIDs generates the next n global IDs.

func (*Meta) GenSchemaVersion Uses

func (m *Meta) GenSchemaVersion() (int64, error)

GenSchemaVersion generates next schema version.

func (*Meta) GenSequenceValue Uses

func (m *Meta) GenSequenceValue(dbID, sequenceID, step int64) (int64, error)

GenSequenceValue adds step to the sequence value and returns the sum.

func (*Meta) GetAllDDLJobsInQueue Uses

func (m *Meta) GetAllDDLJobsInQueue(jobListKeys ...JobListKeyType) ([]*model.Job, error)

GetAllDDLJobsInQueue gets all DDL Jobs in the current queue. The length of jobListKeys can only be 1 or 0. If its length is 1, we need to replace m.jobListKey with jobListKeys[0]. Otherwise, we use m.jobListKey directly.

func (*Meta) GetAllHistoryDDLJobs Uses

func (m *Meta) GetAllHistoryDDLJobs() ([]*model.Job, error)

GetAllHistoryDDLJobs gets all history DDL jobs.

func (*Meta) GetAutoRandomID Uses

func (m *Meta) GetAutoRandomID(dbID int64, tableID int64) (int64, error)

GetAutoRandomID gets current auto shard id with table id.

func (*Meta) GetAutoTableID Uses

func (m *Meta) GetAutoTableID(dbID int64, tableID int64) (int64, error)

GetAutoTableID gets current auto id with table id.

func (*Meta) GetBootstrapVersion Uses

func (m *Meta) GetBootstrapVersion() (int64, error)

GetBootstrapVersion returns the version of the server which bootstrap the store. If the store is not bootstraped, the version will be zero.

func (*Meta) GetDDLJobByIdx Uses

func (m *Meta) GetDDLJobByIdx(index int64, jobListKeys ...JobListKeyType) (*model.Job, error)

GetDDLJobByIdx returns the corresponding DDL job by the index. The length of jobListKeys can only be 1 or 0. If its length is 1, we need to replace m.jobListKey with jobListKeys[0]. Otherwise, we use m.jobListKey directly.

func (*Meta) GetDDLReorgHandle Uses

func (m *Meta) GetDDLReorgHandle(job *model.Job) (startHandle, endHandle, physicalTableID int64, err error)

GetDDLReorgHandle gets the latest processed DDL reorganize position.

func (*Meta) GetDatabase Uses

func (m *Meta) GetDatabase(dbID int64) (*model.DBInfo, error)

GetDatabase gets the database value with ID.

func (*Meta) GetGlobalID Uses

func (m *Meta) GetGlobalID() (int64, error)

GetGlobalID gets current global id.

func (*Meta) GetHistoryDDLJob Uses

func (m *Meta) GetHistoryDDLJob(id int64) (*model.Job, error)

GetHistoryDDLJob gets a history DDL job.

func (*Meta) GetLastHistoryDDLJobsIterator Uses

func (m *Meta) GetLastHistoryDDLJobsIterator() (*LastJobIterator, error)

GetLastHistoryDDLJobsIterator gets latest N history ddl jobs iterator.

func (*Meta) GetLastNHistoryDDLJobs Uses

func (m *Meta) GetLastNHistoryDDLJobs(num int) ([]*model.Job, error)

GetLastNHistoryDDLJobs gets latest N history ddl jobs.

func (*Meta) GetSchemaDiff Uses

func (m *Meta) GetSchemaDiff(schemaVersion int64) (*model.SchemaDiff, error)

GetSchemaDiff gets the modification information on a given schema version.

func (*Meta) GetSchemaVersion Uses

func (m *Meta) GetSchemaVersion() (int64, error)

GetSchemaVersion gets current global schema version.

func (*Meta) GetSequenceCycle Uses

func (m *Meta) GetSequenceCycle(dbID int64, sequenceID int64) (int64, error)

GetSequenceCycle gets current sequence cycle times with sequence id.

func (*Meta) GetSequenceValue Uses

func (m *Meta) GetSequenceValue(dbID int64, sequenceID int64) (int64, error)

GetSequenceValue gets current sequence value with sequence id.

func (*Meta) GetTable Uses

func (m *Meta) GetTable(dbID int64, tableID int64) (*model.TableInfo, error)

GetTable gets the table value in database with tableID.

func (*Meta) ListDatabases Uses

func (m *Meta) ListDatabases() ([]*model.DBInfo, error)

ListDatabases shows all databases.

func (*Meta) ListTables Uses

func (m *Meta) ListTables(dbID int64) ([]*model.TableInfo, error)

ListTables shows all tables in database.

func (*Meta) RemoveDDLReorgHandle Uses

func (m *Meta) RemoveDDLReorgHandle(job *model.Job) error

RemoveDDLReorgHandle removes the job reorganization related handles.

func (*Meta) SetSchemaDiff Uses

func (m *Meta) SetSchemaDiff(diff *model.SchemaDiff) error

SetSchemaDiff sets the modification information on a given schema version.

func (*Meta) SetSequenceCycle Uses

func (m *Meta) SetSequenceCycle(dbID int64, sequenceID int64, round int64) error

SetSequenceCycle sets cycle times value when sequence in cycle.

func (*Meta) SetSequenceValue Uses

func (m *Meta) SetSequenceValue(dbID int64, sequenceID int64, start int64) error

SetSequenceValue sets start value when sequence in cycle.

func (*Meta) UpdateDDLJob Uses

func (m *Meta) UpdateDDLJob(index int64, job *model.Job, updateRawArgs bool, jobListKeys ...JobListKeyType) error

UpdateDDLJob updates the DDL job with index. updateRawArgs is used to determine whether to update the raw args when encode the job. The length of jobListKeys can only be 1 or 0. If its length is 1, we need to replace m.jobListKey with jobListKeys[0]. Otherwise, we use m.jobListKey directly.

func (*Meta) UpdateDDLReorgHandle Uses

func (m *Meta) UpdateDDLReorgHandle(job *model.Job, startHandle, endHandle, physicalTableID int64) error

UpdateDDLReorgHandle saves the job reorganization latest processed information for later resuming.

func (*Meta) UpdateDDLReorgStartHandle Uses

func (m *Meta) UpdateDDLReorgStartHandle(job *model.Job, startHandle int64) error

UpdateDDLReorgStartHandle saves the job reorganization latest processed start handle for later resuming.

func (*Meta) UpdateDatabase Uses

func (m *Meta) UpdateDatabase(dbInfo *model.DBInfo) error

UpdateDatabase updates a database with db info.

func (*Meta) UpdateTable Uses

func (m *Meta) UpdateTable(dbID int64, tableInfo *model.TableInfo) error

UpdateTable updates the table with table info.

Directories

PathSynopsis
autoid

Package meta imports 18 packages (graph) and is imported by 358 packages. Updated 2020-05-28. Refresh now. Tools for package owners.