import "github.com/pingcap/tidb/meta"
var ( // ErrDBExists is the error for db exists. ErrDBExists = dbterror.ClassMeta.NewStd(mysql.ErrDBCreateExists) // ErrDBNotExists is the error for db not exists. ErrDBNotExists = dbterror.ClassMeta.NewStd(mysql.ErrBadDB) // ErrTableExists is the error for table exists. ErrTableExists = dbterror.ClassMeta.NewStd(mysql.ErrTableExists) // ErrTableNotExists is the error for table not exists. ErrTableNotExists = dbterror.ClassMeta.NewStd(mysql.ErrNoSuchTable) // ErrDDLReorgElementNotExist is the error for reorg element not exists. ErrDDLReorgElementNotExist = dbterror.ClassMeta.NewStd(errno.ErrDDLReorgElementNotExist) )
DDLJobHistoryKey is only used for testing.
Element has the information of the backfill job's type and ID.
DecodeElement decodes values from a byte slice generated with an element. It's exported for testing.
EncodeElement encodes an Element into a byte slice. It's exported for testing.
String defines a Stringer function for debugging and pretty printing.
ElementKeyType is a key type of the element.
var ( // ColumnElementKey is the key for column element. ColumnElementKey ElementKeyType = []byte("_col_") // IndexElementKey is the key for index element. IndexElementKey ElementKeyType = []byte("_idx_") )
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 struct {
// contains filtered or unexported fields
}
LastJobIterator is the iterator for gets latest history.
GetLastJobs gets last several jobs.
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(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.
NewSnapshotMeta creates a Meta with snapshot.
AddHistoryDDLJob adds DDL job to history.
CreateDatabase creates a database with db info.
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 (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.
CreateTableOrView creates a table with tableInfo in database.
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.
DeQueueDDLJob pops a DDL job from the list.
DropDatabase drops whole database.
DropSequence drops sequence in database. Sequence is made of table struct and kv value pair.
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.
EnQueueDDLJob adds a DDL job to the list.
FinishBootstrap finishes bootstrap.
GenAutoRandomID adds step to the auto shard ID of the table and returns the sum.
GenAutoTableID adds step to the auto ID of the table and returns the sum.
GenAutoTableIDKeyValue generates meta key by dbID, tableID and corresponding value by autoID.
GenGlobalID generates next id globally.
GenGlobalIDs generates the next n global IDs.
GenSchemaVersion generates next schema version.
GenSequenceValue adds step to the sequence value and returns the sum.
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.
GetAllHistoryDDLJobs gets all history DDL jobs.
GetAutoRandomID gets current auto random id with table id.
GetAutoTableID gets current auto id with table id.
GetBootstrapVersion returns the version of the server which bootstrap the store. If the store is not bootstraped, the version will be zero.
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 (m *Meta) GetDDLReorgHandle(job *model.Job) (element *Element, startKey, endKey kv.Key, physicalTableID int64, err error)
GetDDLReorgHandle gets the latest processed DDL reorganize position.
GetDatabase gets the database value with ID.
GetGlobalID gets current global id.
GetHistoryDDLJob gets a history DDL job.
func (m *Meta) GetLastHistoryDDLJobsIterator() (*LastJobIterator, error)
GetLastHistoryDDLJobsIterator gets latest N history ddl jobs iterator.
GetLastNHistoryDDLJobs gets latest N history ddl jobs.
GetSchemaDiff gets the modification information on a given schema version.
GetSchemaVersion gets current global schema version.
GetSequenceCycle gets current sequence cycle times with sequence id.
GetSequenceValue gets current sequence value with sequence id.
GetTable gets the table value in database with tableID.
ListDatabases shows all databases.
ListTables shows all tables in database.
RemoveDDLReorgHandle removes the job reorganization related handles.
RemoveReorgElement removes the element of the reorganization information. It's used for testing.
RestartSequenceValue resets the the sequence value.
func (m *Meta) SetSchemaDiff(diff *model.SchemaDiff) error
SetSchemaDiff sets the modification information on a given schema version.
SetSequenceCycle sets cycle times value when sequence in cycle.
SetSequenceValue sets start value when sequence in cycle.
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 (m *Meta) UpdateDDLReorgHandle(job *model.Job, startKey, endKey kv.Key, physicalTableID int64, element *Element) error
UpdateDDLReorgHandle saves the job reorganization latest processed information for later resuming.
UpdateDDLReorgStartHandle saves the job reorganization latest processed element and start handle for later resuming.
UpdateDatabase updates a database with db info.
UpdateTable updates the table with table info.
Path | Synopsis |
---|---|
autoid |
Package meta imports 19 packages (graph) and is imported by 360 packages. Updated 2021-01-27. Refresh now. Tools for package owners.