Documentation ¶
Index ¶
- Variables
- func DDLJobHistoryKey(m *Meta, jobID int64) []byte
- type JobListKeyType
- type Meta
- func (m *Meta) AddHistoryDDLJob(job *model.Job) error
- func (m *Meta) CreateDatabase(dbInfo *model.DBInfo) error
- func (m *Meta) CreateTableAndSetAutoID(dbID int64, tableInfo *model.TableInfo, autoID int64) error
- func (m *Meta) CreateTableOrView(dbID int64, tableInfo *model.TableInfo) error
- func (m *Meta) DDLJobQueueLen(jobListKeys ...JobListKeyType) (int64, error)
- func (m *Meta) DeQueueDDLJob() (*model.Job, error)
- func (m *Meta) DropDatabase(dbID int64) error
- func (m *Meta) DropTableOrView(dbID int64, tblID int64, delAutoID bool) error
- func (m *Meta) EnQueueDDLJob(job *model.Job) error
- func (m *Meta) FinishBootstrap(version int64) error
- func (m *Meta) GenAutoTableID(dbID, tableID, step int64) (int64, error)
- func (m *Meta) GenAutoTableIDKeyValue(dbID, tableID, autoID int64) (key, value []byte)
- func (m *Meta) GenGlobalID() (int64, error)
- func (m *Meta) GenSchemaVersion() (int64, error)
- func (m *Meta) GetAllDDLJobsInQueue(jobListKeys ...JobListKeyType) ([]*model.Job, error)
- func (m *Meta) GetAllHistoryDDLJobs() ([]*model.Job, error)
- func (m *Meta) GetAutoTableID(dbID int64, tableID int64) (int64, error)
- func (m *Meta) GetBootstrapVersion() (int64, error)
- func (m *Meta) GetDDLJobByIdx(index int64, jobListKeys ...JobListKeyType) (*model.Job, error)
- func (m *Meta) GetDDLReorgHandle(job *model.Job) (startHandle, endHandle, physicalTableID int64, err error)
- func (m *Meta) GetDatabase(dbID int64) (*model.DBInfo, error)
- func (m *Meta) GetGlobalID() (int64, error)
- func (m *Meta) GetHistoryDDLJob(id int64) (*model.Job, error)
- func (m *Meta) GetLastNHistoryDDLJobs(num int) ([]*model.Job, error)
- func (m *Meta) GetSchemaDiff(schemaVersion int64) (*model.SchemaDiff, error)
- func (m *Meta) GetSchemaVersion() (int64, error)
- func (m *Meta) GetTable(dbID int64, tableID int64) (*model.TableInfo, error)
- func (m *Meta) ListDatabases() ([]*model.DBInfo, error)
- func (m *Meta) ListTables(dbID int64) ([]*model.TableInfo, error)
- func (m *Meta) RemoveDDLReorgHandle(job *model.Job) error
- func (m *Meta) SetSchemaDiff(diff *model.SchemaDiff) error
- func (m *Meta) UpdateDDLJob(index int64, job *model.Job, updateRawArgs bool, jobListKeys ...JobListKeyType) error
- func (m *Meta) UpdateDDLReorgHandle(job *model.Job, startHandle, endHandle, physicalTableID int64) error
- func (m *Meta) UpdateDDLReorgStartHandle(job *model.Job, startHandle int64) error
- func (m *Meta) UpdateDatabase(dbInfo *model.DBInfo) error
- func (m *Meta) UpdateTable(dbID int64, tableInfo *model.TableInfo) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDBExists is the error for db exists. ErrDBExists = terror.ClassMeta.New(codeDatabaseExists, "database already exists") // ErrDBNotExists is the error for db not exists. ErrDBNotExists = terror.ClassMeta.New(codeDatabaseNotExists, "database doesn't exist") // ErrTableExists is the error for table exists. ErrTableExists = terror.ClassMeta.New(codeTableExists, "table already exists") // ErrTableNotExists is the error for table not exists. ErrTableNotExists = terror.ClassMeta.New(codeTableNotExists, "table doesn't exist") )
Functions ¶
func DDLJobHistoryKey ¶
DDLJobHistoryKey is only used for testing.
Types ¶
type JobListKeyType ¶
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 Meta ¶
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 ¶
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 ¶
NewSnapshotMeta creates a Meta with snapshot.
func (*Meta) AddHistoryDDLJob ¶
AddHistoryDDLJob adds DDL job to history.
func (*Meta) CreateDatabase ¶
CreateDatabase creates a database with db info.
func (*Meta) CreateTableAndSetAutoID ¶
CreateTableAndSetAutoID creates a table with tableInfo in database, and rebases the table autoID.
func (*Meta) CreateTableOrView ¶
CreateTableOrView creates a table with tableInfo in database.
func (*Meta) DDLJobQueueLen ¶
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 ¶
DeQueueDDLJob pops a DDL job from the list.
func (*Meta) DropDatabase ¶
DropDatabase drops whole database.
func (*Meta) DropTableOrView ¶
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 ¶
EnQueueDDLJob adds a DDL job to the list.
func (*Meta) FinishBootstrap ¶
FinishBootstrap finishes bootstrap.
func (*Meta) GenAutoTableID ¶
GenAutoTableID adds step to the auto ID of the table and returns the sum.
func (*Meta) GenAutoTableIDKeyValue ¶
GenAutoTableIDKeyValue generates meta key by dbID, tableID and corresponding value by autoID.
func (*Meta) GenGlobalID ¶
GenGlobalID generates next id globally.
func (*Meta) GenSchemaVersion ¶
GenSchemaVersion generates next schema version.
func (*Meta) GetAllDDLJobsInQueue ¶
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 ¶
GetAllHistoryDDLJobs gets all history DDL jobs.
func (*Meta) GetAutoTableID ¶
GetAutoTableID gets current auto id with table id.
func (*Meta) GetBootstrapVersion ¶
GetBootstrapVersion returns the version of the server which boostrap the store. If the store is not bootstraped, the version will be zero.
func (*Meta) GetDDLJobByIdx ¶
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 ¶
func (m *Meta) GetDDLReorgHandle(job *model.Job) (startHandle, endHandle, physicalTableID int64, err error)
GetDDLReorgHandle gets the latest processed DDL reorganize position.
func (*Meta) GetDatabase ¶
GetDatabase gets the database value with ID.
func (*Meta) GetGlobalID ¶
GetGlobalID gets current global id.
func (*Meta) GetHistoryDDLJob ¶
GetHistoryDDLJob gets a history DDL job.
func (*Meta) GetLastNHistoryDDLJobs ¶
GetLastNHistoryDDLJobs gets latest N history ddl jobs.
func (*Meta) GetSchemaDiff ¶
func (m *Meta) GetSchemaDiff(schemaVersion int64) (*model.SchemaDiff, error)
GetSchemaDiff gets the modification information on a given schema version.
func (*Meta) GetSchemaVersion ¶
GetSchemaVersion gets current global schema version.
func (*Meta) ListDatabases ¶
ListDatabases shows all databases.
func (*Meta) ListTables ¶
ListTables shows all tables in database.
func (*Meta) RemoveDDLReorgHandle ¶
RemoveDDLReorgHandle removes the job reorganization related handles.
func (*Meta) SetSchemaDiff ¶
func (m *Meta) SetSchemaDiff(diff *model.SchemaDiff) error
SetSchemaDiff sets the modification information on a given schema version.
func (*Meta) UpdateDDLJob ¶
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 ¶
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 ¶
UpdateDDLReorgStartHandle saves the job reorganization latest processed start handle for later resuming.
func (*Meta) UpdateDatabase ¶
UpdateDatabase updates a database with db info.