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

package ddl

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


Package Files

callback.go column.go ddl.go ddl_algorithm.go ddl_api.go ddl_worker.go delete_range.go foreign_key.go generated_column.go index.go mock.go options.go partition.go reorg.go rollingback.go schema.go session_pool.go split_region.go stat.go table.go table_lock.go


const (

    // DDLOwnerKey is the ddl owner path that is saved to etcd, and it's exported for testing.
    DDLOwnerKey = "/tidb/ddl/fg/owner"

    // PartitionCountLimit is limit of the number of partitions in a table.
    // Mysql maximum number of partitions is 8192, our maximum number of partitions is 1024.
    // Reference linking https://dev.mysql.com/doc/refman/5.7/en/partitioning-limitations.html.
    PartitionCountLimit = 1024
const (
    // DefaultTaskHandleCnt is default batch size of adding indices.
    DefaultTaskHandleCnt = 128
const (

    // MaxCommentLength is exported for testing.
    MaxCommentLength = 1024


var (
    // TableColumnCountLimit is limit of the number of columns in a table.
    // It's exported for testing.
    TableColumnCountLimit = uint32(512)
    // EnableSplitTableRegion is a flag to decide whether to split a new region for
    // a newly created table. It takes effect only if the Storage supports split
    // region.
    EnableSplitTableRegion = uint32(0)
var (

    // ErrInvalidDefaultValue returns for invalid default value for columns.
    ErrInvalidDefaultValue = terror.ClassDDL.New(mysql.ErrInvalidDefault, mysql.MySQLErrName[mysql.ErrInvalidDefault])
    // ErrGeneratedColumnRefAutoInc forbids to refer generated columns to auto-increment columns .
    ErrGeneratedColumnRefAutoInc = terror.ClassDDL.New(mysql.ErrGeneratedColumnRefAutoInc, mysql.MySQLErrName[mysql.ErrGeneratedColumnRefAutoInc])
    // ErrUnsupportedAddPartition returns for does not support add partitions.
    ErrUnsupportedAddPartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "add partitions"))
    // ErrUnsupportedCoalescePartition returns for does not support coalesce partitions.
    ErrUnsupportedCoalescePartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "coalesce partitions"))
    // ErrGeneratedColumnFunctionIsNotAllowed returns for unsupported functions for generated columns.
    ErrGeneratedColumnFunctionIsNotAllowed = terror.ClassDDL.New(mysql.ErrGeneratedColumnFunctionIsNotAllowed, mysql.MySQLErrName[mysql.ErrGeneratedColumnFunctionIsNotAllowed])
    // ErrUnsupportedPartitionByRangeColumns returns for does unsupported partition by range columns.
    ErrUnsupportedPartitionByRangeColumns = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "partition by range columns"))

    // ErrDupKeyName returns for duplicated key name
    ErrDupKeyName = terror.ClassDDL.New(mysql.ErrDupKeyName, mysql.MySQLErrName[mysql.ErrDupKeyName])
    // ErrInvalidDDLState returns for invalid ddl model object state.
    ErrInvalidDDLState = terror.ClassDDL.New(mysql.ErrInvalidDDLState, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrInvalidDDLState]))
    // ErrUnsupportedModifyPrimaryKey returns an error when add or drop the primary key.
    // It's exported for testing.
    ErrUnsupportedModifyPrimaryKey = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "%s primary key"))

    // ErrColumnBadNull returns for a bad null value.
    ErrColumnBadNull = terror.ClassDDL.New(mysql.ErrBadNull, mysql.MySQLErrName[mysql.ErrBadNull])
    // ErrBadField forbids to refer to unknown column.
    ErrBadField = terror.ClassDDL.New(mysql.ErrBadField, mysql.MySQLErrName[mysql.ErrBadField])
    // ErrCantRemoveAllFields returns for deleting all columns.
    ErrCantRemoveAllFields = terror.ClassDDL.New(mysql.ErrCantRemoveAllFields, mysql.MySQLErrName[mysql.ErrCantRemoveAllFields])
    // ErrCantDropFieldOrKey returns for dropping a non-existent field or key.
    ErrCantDropFieldOrKey = terror.ClassDDL.New(mysql.ErrCantDropFieldOrKey, mysql.MySQLErrName[mysql.ErrCantDropFieldOrKey])
    // ErrInvalidOnUpdate returns for invalid ON UPDATE clause.
    ErrInvalidOnUpdate = terror.ClassDDL.New(mysql.ErrInvalidOnUpdate, mysql.MySQLErrName[mysql.ErrInvalidOnUpdate])
    // ErrTooLongIdent returns for too long name of database/table/column/index.
    ErrTooLongIdent = terror.ClassDDL.New(mysql.ErrTooLongIdent, mysql.MySQLErrName[mysql.ErrTooLongIdent])
    // ErrWrongDBName returns for wrong database name.
    ErrWrongDBName = terror.ClassDDL.New(mysql.ErrWrongDBName, mysql.MySQLErrName[mysql.ErrWrongDBName])
    // ErrWrongTableName returns for wrong table name.
    ErrWrongTableName = terror.ClassDDL.New(mysql.ErrWrongTableName, mysql.MySQLErrName[mysql.ErrWrongTableName])
    // ErrWrongColumnName returns for wrong column name.
    ErrWrongColumnName = terror.ClassDDL.New(mysql.ErrWrongColumnName, mysql.MySQLErrName[mysql.ErrWrongColumnName])
    // ErrInvalidGroupFuncUse returns for using invalid group functions.
    ErrInvalidGroupFuncUse = terror.ClassDDL.New(mysql.ErrInvalidGroupFuncUse, mysql.MySQLErrName[mysql.ErrInvalidGroupFuncUse])
    // ErrTableMustHaveColumns returns for missing column when creating a table.
    ErrTableMustHaveColumns = terror.ClassDDL.New(mysql.ErrTableMustHaveColumns, mysql.MySQLErrName[mysql.ErrTableMustHaveColumns])
    // ErrWrongNameForIndex returns for wrong index name.
    ErrWrongNameForIndex = terror.ClassDDL.New(mysql.ErrWrongNameForIndex, mysql.MySQLErrName[mysql.ErrWrongNameForIndex])
    // ErrUnknownCharacterSet returns unknown character set.
    ErrUnknownCharacterSet = terror.ClassDDL.New(mysql.ErrUnknownCharacterSet, mysql.MySQLErrName[mysql.ErrUnknownCharacterSet])
    // ErrUnknownCollation returns unknown collation.
    ErrUnknownCollation = terror.ClassDDL.New(mysql.ErrUnknownCollation, mysql.MySQLErrName[mysql.ErrUnknownCollation])
    // ErrCollationCharsetMismatch returns when collation not match the charset.
    ErrCollationCharsetMismatch = terror.ClassDDL.New(mysql.ErrCollationCharsetMismatch, mysql.MySQLErrName[mysql.ErrCollationCharsetMismatch])
    // ErrConflictingDeclarations return conflict declarations.
    ErrConflictingDeclarations = terror.ClassDDL.New(mysql.ErrConflictingDeclarations, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrConflictingDeclarations], "CHARACTER SET ", "%s", "CHARACTER SET ", "%s"))
    // ErrPrimaryCantHaveNull returns All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead
    ErrPrimaryCantHaveNull = terror.ClassDDL.New(mysql.ErrPrimaryCantHaveNull, mysql.MySQLErrName[mysql.ErrPrimaryCantHaveNull])
    // ErrErrorOnRename returns error for wrong database name in alter table rename
    ErrErrorOnRename = terror.ClassDDL.New(mysql.ErrErrorOnRename, mysql.MySQLErrName[mysql.ErrErrorOnRename])

    // ErrNotAllowedTypeInPartition returns not allowed type error when creating table partition with unsupported expression type.
    ErrNotAllowedTypeInPartition = terror.ClassDDL.New(mysql.ErrFieldTypeNotAllowedAsPartitionField, mysql.MySQLErrName[mysql.ErrFieldTypeNotAllowedAsPartitionField])
    // ErrPartitionMgmtOnNonpartitioned returns it's not a partition table.
    ErrPartitionMgmtOnNonpartitioned = terror.ClassDDL.New(mysql.ErrPartitionMgmtOnNonpartitioned, mysql.MySQLErrName[mysql.ErrPartitionMgmtOnNonpartitioned])
    // ErrDropPartitionNonExistent returns error in list of partition.
    ErrDropPartitionNonExistent = terror.ClassDDL.New(mysql.ErrDropPartitionNonExistent, mysql.MySQLErrName[mysql.ErrDropPartitionNonExistent])
    // ErrSameNamePartition returns duplicate partition name.
    ErrSameNamePartition = terror.ClassDDL.New(mysql.ErrSameNamePartition, mysql.MySQLErrName[mysql.ErrSameNamePartition])
    // ErrRangeNotIncreasing returns values less than value must be strictly increasing for each partition.
    ErrRangeNotIncreasing = terror.ClassDDL.New(mysql.ErrRangeNotIncreasing, mysql.MySQLErrName[mysql.ErrRangeNotIncreasing])
    // ErrPartitionMaxvalue returns maxvalue can only be used in last partition definition.
    ErrPartitionMaxvalue = terror.ClassDDL.New(mysql.ErrPartitionMaxvalue, mysql.MySQLErrName[mysql.ErrPartitionMaxvalue])
    //ErrDropLastPartition returns cannot remove all partitions, use drop table instead.
    ErrDropLastPartition = terror.ClassDDL.New(mysql.ErrDropLastPartition, mysql.MySQLErrName[mysql.ErrDropLastPartition])
    //ErrTooManyPartitions returns too many partitions were defined.
    ErrTooManyPartitions = terror.ClassDDL.New(mysql.ErrTooManyPartitions, mysql.MySQLErrName[mysql.ErrTooManyPartitions])
    //ErrPartitionFunctionIsNotAllowed returns this partition function is not allowed.
    ErrPartitionFunctionIsNotAllowed = terror.ClassDDL.New(mysql.ErrPartitionFunctionIsNotAllowed, mysql.MySQLErrName[mysql.ErrPartitionFunctionIsNotAllowed])
    // ErrPartitionFuncNotAllowed returns partition function returns the wrong type.
    ErrPartitionFuncNotAllowed = terror.ClassDDL.New(mysql.ErrPartitionFuncNotAllowed, mysql.MySQLErrName[mysql.ErrPartitionFuncNotAllowed])
    // ErrUniqueKeyNeedAllFieldsInPf returns must include all columns in the table's partitioning function.
    ErrUniqueKeyNeedAllFieldsInPf = terror.ClassDDL.New(mysql.ErrUniqueKeyNeedAllFieldsInPf, mysql.MySQLErrName[mysql.ErrUniqueKeyNeedAllFieldsInPf])

    // ErrWarnDataTruncated returns data truncated error.
    ErrWarnDataTruncated = terror.ClassDDL.New(mysql.WarnDataTruncated, mysql.MySQLErrName[mysql.WarnDataTruncated])
    // ErrCoalesceOnlyOnHashPartition returns coalesce partition can only be used on hash/key partitions.
    ErrCoalesceOnlyOnHashPartition = terror.ClassDDL.New(mysql.ErrCoalesceOnlyOnHashPartition, mysql.MySQLErrName[mysql.ErrCoalesceOnlyOnHashPartition])
    // ErrViewWrongList returns create view must include all columns in the select clause
    ErrViewWrongList = terror.ClassDDL.New(mysql.ErrViewWrongList, mysql.MySQLErrName[mysql.ErrViewWrongList])
    // ErrAlterOperationNotSupported returns when alter operations is not supported.
    ErrAlterOperationNotSupported = terror.ClassDDL.New(mysql.ErrAlterOperationNotSupportedReason, mysql.MySQLErrName[mysql.ErrAlterOperationNotSupportedReason])
    // ErrWrongObject returns for wrong object.
    ErrWrongObject = terror.ClassDDL.New(mysql.ErrWrongObject, mysql.MySQLErrName[mysql.ErrWrongObject])
    // ErrTableCantHandleFt returns FULLTEXT keys are not supported by table type
    ErrTableCantHandleFt = terror.ClassDDL.New(mysql.ErrTableCantHandleFt, mysql.MySQLErrName[mysql.ErrTableCantHandleFt])
    // ErrFieldNotFoundPart returns an error when 'partition by columns' are not found in table columns.
    ErrFieldNotFoundPart = terror.ClassDDL.New(mysql.ErrFieldNotFoundPart, mysql.MySQLErrName[mysql.ErrFieldNotFoundPart])
    // ErrWrongTypeColumnValue returns 'Partition column values of incorrect type'
    ErrWrongTypeColumnValue = terror.ClassDDL.New(mysql.ErrWrongTypeColumnValue, mysql.MySQLErrName[mysql.ErrWrongTypeColumnValue])
var (
    // RunWorker indicates if this TiDB server starts DDL worker and can run DDL job.
    RunWorker = true

    // WaitTimeWhenErrorOccured is waiting interval when processing DDL jobs encounter errors.
    WaitTimeWhenErrorOccured = 1 * time.Second
var (
    // TestCheckWorkerNumCh use for test adjust add index worker.
    TestCheckWorkerNumCh = make(chan struct{})
    // TestCheckWorkerNumber use for test adjust add index worker.
    TestCheckWorkerNumber = int32(16)
var ReorgWaitTimeout = 5 * time.Second

ReorgWaitTimeout is the timeout that wait ddl in write reorganization stage.

func BuildTableInfoFromAST Uses

func BuildTableInfoFromAST(s *ast.CreateTableStmt) (*model.TableInfo, error)

BuildTableInfoFromAST builds model.TableInfo from a SQL statement. The SQL string should be a create table statement. Don't use this function to build a partitioned table.

func EmulatorGCDisable Uses

func EmulatorGCDisable()

EmulatorGCDisable disables emulator gc. It exports for testing.

func EmulatorGCEnable Uses

func EmulatorGCEnable()

EmulatorGCEnable enables emulator gc. It exports for testing.

func IsEmulatorGCEnable Uses

func IsEmulatorGCEnable() bool

IsEmulatorGCEnable indicates whether emulator GC enabled. It exports for testing.

func IsTooBigFieldLength Uses

func IsTooBigFieldLength(colDefTpFlen int, colDefName, setCharset string) error

IsTooBigFieldLength check if the varchar type column exceeds the maximum length limit.

func MockTableInfo Uses

func MockTableInfo(ctx sessionctx.Context, stmt *ast.CreateTableStmt, tableID int64) (*model.TableInfo, error)

MockTableInfo mocks a table info by create table stmt ast and a specified table id.

func NewMockSchemaSyncer Uses

func NewMockSchemaSyncer() util.SchemaSyncer

NewMockSchemaSyncer creates a new mock SchemaSyncer.

func ResolveAlterAlgorithm Uses

func ResolveAlterAlgorithm(alterSpec *ast.AlterTableSpec, specify ast.AlgorithmType) (ast.AlgorithmType, error)

ResolveAlterAlgorithm resolves the algorithm of the alterSpec. If specify algorithm is not supported by the alter action, errAlterOperationNotSupported will be returned. If specify is the ast.AlterAlgorithmDefault, then the default algorithm of the alter action will be returned.

func ResolveCharsetCollation Uses

func ResolveCharsetCollation(tblCharset, tblCollate, dbCharset, dbCollate string) (string, string, error)

ResolveCharsetCollation will resolve the charset by the order: table charset > database charset > server default charset, and it will also resolve the collate by the order: table collate > database collate > server default collate.

type AlterAlgorithm Uses

type AlterAlgorithm struct {
    // contains filtered or unexported fields

AlterAlgorithm is used to store supported alter algorithm. For now, TiDB only support AlterAlgorithmInplace and AlterAlgorithmInstant. The most alter operations are using instant algorithm, and only the add index is using inplace(not really inplace, because we never block the DML but costs some time to backfill the index data) See https://dev.mysql.com/doc/refman/8.0/en/alter-table.html#alter-table-performance.

type BaseCallback Uses

type BaseCallback struct {

BaseCallback implements Callback.OnChanged interface.

func (*BaseCallback) OnChanged Uses

func (c *BaseCallback) OnChanged(err error) error

OnChanged implements Callback interface.

func (*BaseCallback) OnJobRunBefore Uses

func (c *BaseCallback) OnJobRunBefore(job *model.Job)

OnJobRunBefore implements Callback.OnJobRunBefore interface.

func (*BaseCallback) OnJobUpdated Uses

func (c *BaseCallback) OnJobUpdated(job *model.Job)

OnJobUpdated implements Callback.OnJobUpdated interface.

func (*BaseCallback) OnWatched Uses

func (c *BaseCallback) OnWatched(ctx context.Context)

OnWatched implements Callback.OnWatched interface.

type BaseInterceptor Uses

type BaseInterceptor struct{}

BaseInterceptor implements Interceptor.

func (*BaseInterceptor) OnGetInfoSchema Uses

func (bi *BaseInterceptor) OnGetInfoSchema(ctx sessionctx.Context, is infoschema.InfoSchema) infoschema.InfoSchema

OnGetInfoSchema implements Interceptor.OnGetInfoSchema interface.

type Callback Uses

type Callback interface {
    // OnChanged is called after schema is changed.
    OnChanged(err error) error
    // OnJobRunBefore is called before running job.
    OnJobRunBefore(job *model.Job)
    // OnJobUpdated is called after the running job is updated.
    OnJobUpdated(job *model.Job)
    // OnWatched is called after watching owner is completed.
    OnWatched(ctx context.Context)

Callback is used for DDL.

type DDL Uses

type DDL interface {
    CreateSchema(ctx sessionctx.Context, name model.CIStr, charsetInfo *ast.CharsetOpt) error
    AlterSchema(ctx sessionctx.Context, stmt *ast.AlterDatabaseStmt) error
    DropSchema(ctx sessionctx.Context, schema model.CIStr) error
    CreateTable(ctx sessionctx.Context, stmt *ast.CreateTableStmt) error
    CreateView(ctx sessionctx.Context, stmt *ast.CreateViewStmt) error
    CreateTableWithLike(ctx sessionctx.Context, ident, referIdent ast.Ident, ifNotExists bool) error
    DropTable(ctx sessionctx.Context, tableIdent ast.Ident) (err error)
    RecoverTable(ctx sessionctx.Context, tbInfo *model.TableInfo, schemaID, autoID, dropJobID int64, snapshotTS uint64) (err error)
    DropView(ctx sessionctx.Context, tableIdent ast.Ident) (err error)
    CreateIndex(ctx sessionctx.Context, tableIdent ast.Ident, keyType ast.IndexKeyType, indexName model.CIStr,
        columnNames []*ast.IndexColName, indexOption *ast.IndexOption, ifNotExists bool) error
    DropIndex(ctx sessionctx.Context, tableIdent ast.Ident, indexName model.CIStr, ifExists bool) error
    AlterTable(ctx sessionctx.Context, tableIdent ast.Ident, spec []*ast.AlterTableSpec) error
    TruncateTable(ctx sessionctx.Context, tableIdent ast.Ident) error
    RenameTable(ctx sessionctx.Context, oldTableIdent, newTableIdent ast.Ident, isAlterTable bool) error
    LockTables(ctx sessionctx.Context, stmt *ast.LockTablesStmt) error
    UnlockTables(ctx sessionctx.Context, lockedTables []model.TableLockTpInfo) error
    CleanupTableLock(ctx sessionctx.Context, tables []*ast.TableName) error
    UpdateTableReplicaInfo(ctx sessionctx.Context, tid int64, available bool) error

    // GetLease returns current schema lease time.
    GetLease() time.Duration
    // Stats returns the DDL statistics.
    Stats(vars *variable.SessionVars) (map[string]interface{}, error)
    // GetScope gets the status variables scope.
    GetScope(status string) variable.ScopeFlag
    // Stop stops DDL worker.
    Stop() error
    // RegisterEventCh registers event channel for ddl.
    RegisterEventCh(chan<- *util.Event)
    // SchemaSyncer gets the schema syncer.
    SchemaSyncer() util.SchemaSyncer
    // OwnerManager gets the owner manager.
    OwnerManager() owner.Manager
    // GetID gets the ddl ID.
    GetID() string
    // GetTableMaxRowID gets the max row ID of a normal table or a partition.
    GetTableMaxRowID(startTS uint64, tbl table.PhysicalTable) (int64, bool, error)
    // SetBinlogClient sets the binlog client for DDL worker. It's exported for testing.
    // GetHook gets the hook. It's exported for testing.
    GetHook() Callback

DDL is responsible for updating schema in data store and maintaining in-memory InfoSchema cache.

func NewDDL Uses

func NewDDL(ctx context.Context, options ...Option) DDL

NewDDL creates a new DDL.

type Interceptor Uses

type Interceptor interface {
    // OnGetInfoSchema is an intercept which is called in the function ddl.GetInfoSchema(). It is used in the tests.
    OnGetInfoSchema(ctx sessionctx.Context, is infoschema.InfoSchema) infoschema.InfoSchema

Interceptor is used for DDL.

type MockSchemaSyncer Uses

type MockSchemaSyncer struct {
    // contains filtered or unexported fields

MockSchemaSyncer is a mock schema syncer, it is exported for tesing.

func (*MockSchemaSyncer) CloseCleanWork Uses

func (s *MockSchemaSyncer) CloseCleanWork()

CloseCleanWork implements SchemaSyncer.CloseCleanWork interface.

func (*MockSchemaSyncer) CloseSession Uses

func (s *MockSchemaSyncer) CloseSession()

CloseSession mockSession, it is exported for testing.

func (*MockSchemaSyncer) Done Uses

func (s *MockSchemaSyncer) Done() <-chan struct{}

Done implements SchemaSyncer.Done interface.

func (*MockSchemaSyncer) GlobalVersionCh Uses

func (s *MockSchemaSyncer) GlobalVersionCh() clientv3.WatchChan

GlobalVersionCh implements SchemaSyncer.GlobalVersionCh interface.

func (*MockSchemaSyncer) Init Uses

func (s *MockSchemaSyncer) Init(ctx context.Context) error

Init implements SchemaSyncer.Init interface.

func (*MockSchemaSyncer) MustGetGlobalVersion Uses

func (s *MockSchemaSyncer) MustGetGlobalVersion(ctx context.Context) (int64, error)

MustGetGlobalVersion implements SchemaSyncer.MustGetGlobalVersion interface.

func (*MockSchemaSyncer) NotifyCleanExpiredPaths Uses

func (s *MockSchemaSyncer) NotifyCleanExpiredPaths() bool

NotifyCleanExpiredPaths implements SchemaSyncer.NotifyCleanExpiredPaths interface.

func (*MockSchemaSyncer) OwnerCheckAllVersions Uses

func (s *MockSchemaSyncer) OwnerCheckAllVersions(ctx context.Context, latestVer int64) error

OwnerCheckAllVersions implements SchemaSyncer.OwnerCheckAllVersions interface.

func (*MockSchemaSyncer) OwnerUpdateGlobalVersion Uses

func (s *MockSchemaSyncer) OwnerUpdateGlobalVersion(ctx context.Context, version int64) error

OwnerUpdateGlobalVersion implements SchemaSyncer.OwnerUpdateGlobalVersion interface.

func (*MockSchemaSyncer) RemoveSelfVersionPath Uses

func (s *MockSchemaSyncer) RemoveSelfVersionPath() error

RemoveSelfVersionPath implements SchemaSyncer.RemoveSelfVersionPath interface.

func (*MockSchemaSyncer) Restart Uses

func (s *MockSchemaSyncer) Restart(_ context.Context) error

Restart implements SchemaSyncer.Restart interface.

func (*MockSchemaSyncer) StartCleanWork Uses

func (s *MockSchemaSyncer) StartCleanWork()

StartCleanWork implements SchemaSyncer.StartCleanWork interface.

func (*MockSchemaSyncer) UpdateSelfVersion Uses

func (s *MockSchemaSyncer) UpdateSelfVersion(ctx context.Context, version int64) error

UpdateSelfVersion implements SchemaSyncer.UpdateSelfVersion interface.

func (*MockSchemaSyncer) WatchGlobalSchemaVer Uses

func (s *MockSchemaSyncer) WatchGlobalSchemaVer(context.Context)

WatchGlobalSchemaVer implements SchemaSyncer.WatchGlobalSchemaVer interface.

type Option Uses

type Option func(*Options)

Option represents an option to initialize the DDL module

func WithEtcdClient Uses

func WithEtcdClient(client *clientv3.Client) Option

WithEtcdClient specifies the `clientv3.Client` of DDL used to request the etcd service

func WithHook Uses

func WithHook(callback Callback) Option

WithHook specifies the `Callback` of DDL used to notify the outer module when events are triggered

func WithInfoHandle Uses

func WithInfoHandle(ih *infoschema.Handle) Option

WithInfoHandle specifies the `infoschema.Handle`

func WithLease Uses

func WithLease(lease time.Duration) Option

WithLease specifies the schema lease duration

func WithResourcePool Uses

func WithResourcePool(pools *pools.ResourcePool) Option

WithResourcePool specifies the `pools.ResourcePool` of DDL used

func WithStore Uses

func WithStore(store kv.Storage) Option

WithStore specifies the `kv.Storage` of DDL used to request the KV service

type Options Uses

type Options struct {
    EtcdCli      *clientv3.Client
    Store        kv.Storage
    InfoHandle   *infoschema.Handle
    Hook         Callback
    Lease        time.Duration
    ResourcePool *pools.ResourcePool

Options represents all the options of the DDL module needs



Package ddl imports 59 packages (graph) and is imported by 190 packages. Updated 2019-11-20. Refresh now. Tools for package owners.