Documentation ¶
Index ¶
- func IsTableNotExists(err error) bool
- type DownstreamTableInfo
- type Tracker
- func (tr *Tracker) AllSchemas() []string
- func (tr *Tracker) BatchCreateTableIfNotExist(tablesToCreate map[string]map[string]*model.TableInfo) error
- func (tr *Tracker) Close()
- func (tr *Tracker) CreateSchemaIfNotExists(db string) error
- func (tr *Tracker) CreateTableIfNotExists(table *filter.Table, ti *model.TableInfo) error
- func (tr *Tracker) DropTable(table *filter.Table) error
- func (tr *Tracker) Exec(ctx context.Context, db string, stmt ast.StmtNode) (errRet error)
- func (tr *Tracker) GetCreateTable(ctx context.Context, table *filter.Table) (string, error)
- func (tr *Tracker) GetDownStreamTableInfo(tctx *tcontext.Context, tableID string, originTI *model.TableInfo) (*DownstreamTableInfo, error)
- func (tr *Tracker) GetSingleColumnIndices(db, tbl, col string) ([]*model.IndexInfo, error)
- func (tr *Tracker) GetTableInfo(table *filter.Table) (*model.TableInfo, error)
- func (tr *Tracker) Init(ctx context.Context, task string, lowerCaseTableNames int, ...) error
- func (tr *Tracker) ListSchemaTables(schema string) ([]string, error)
- func (tr *Tracker) RemoveDownstreamSchema(tctx *tcontext.Context, targetTables []*filter.Table)
- func (tr *Tracker) Reset()
- func (tr *Tracker) SplitBatchCreateTableAndHandle(schema pmodel.CIStr, info []*model.TableInfo, l int, r int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTableNotExists ¶
IsTableNotExists checks if err means the database or table does not exist.
Types ¶
type DownstreamTableInfo ¶
type DownstreamTableInfo struct { TableInfo *model.TableInfo // tableInfo which comes from parse create statement syntaxtree WhereHandle *sqlmodel.WhereHandle }
DownstreamTableInfo contains tableinfo and index cache.
type Tracker ¶
type Tracker struct { // The Tracker uses tidb DDL library to track table structure changes. // where there was basically no parallel operation at the beginning. // However, since the validator is introduced and heavily dependent on the Tracker, we need to make sure // the synchronization between the reading from the validator and the modification from the syncer (e.g. // when the checkpoint is being rolled back, we have to make sure the validator can still vision the original tables) // From this point, we add an extra layer of the synchronization for the following operations: // 1. GetTableInfo: the validator reads table infos. // 2. Init: when the syncer restarts, it may re-initialize the Tracker while the validator may read the Tracker at the same time. // 3. Close: Being similar as above, the validator can read the Tracker while the syncer is closing the Tracker. sync.RWMutex // contains filtered or unexported fields }
Tracker is used to track schema locally.
func NewTestTracker ¶
func NewTestTracker( ctx context.Context, task string, downstreamConn *dbconn.DBConn, logger log.Logger, ) (*Tracker, error)
NewTestTracker creates an empty Tracker and initializes it subsequently. It is useful for test.
func NewTracker ¶
func NewTracker() *Tracker
NewTracker simply returns an empty Tracker, which should be followed by an initialization before used.
func (*Tracker) AllSchemas ¶
AllSchemas returns all schemas visible to the tracker (excluding system tables).
func (*Tracker) BatchCreateTableIfNotExist ¶
func (tr *Tracker) BatchCreateTableIfNotExist(tablesToCreate map[string]map[string]*model.TableInfo) error
BatchCreateTableIfNotExist will batch creating tables per schema. If the schema does not exist, it will create it. The argument is { database name -> { table name -> TableInfo } }.
func (*Tracker) CreateSchemaIfNotExists ¶
CreateSchemaIfNotExists creates a SCHEMA of the given name if it did not exist.
func (*Tracker) CreateTableIfNotExists ¶
CreateTableIfNotExists creates a TABLE of the given name if it did not exist.
func (*Tracker) GetCreateTable ¶
GetCreateTable returns the `CREATE TABLE` statement of the table.
func (*Tracker) GetDownStreamTableInfo ¶
func (tr *Tracker) GetDownStreamTableInfo(tctx *tcontext.Context, tableID string, originTI *model.TableInfo) (*DownstreamTableInfo, error)
GetDownStreamTableInfo gets downstream table info. note. this function will init downstreamTrack's table info.
func (*Tracker) GetSingleColumnIndices ¶
GetSingleColumnIndices returns indices of input column if input column only has single-column indices returns nil if input column has no indices, or has multi-column indices. TODO: move out of this package!
func (*Tracker) GetTableInfo ¶
GetTableInfo returns the schema associated with the table.
func (*Tracker) Init ¶
func (tr *Tracker) Init( ctx context.Context, task string, lowerCaseTableNames int, downstreamConn *dbconn.DBConn, logger log.Logger, ) error
Init initializes the Tracker. `sessionCfg` will be set as tracker's session variables if specified, or retrieve some variable from downstream using `downstreamConn`. NOTE **sessionCfg is a reference to caller**.
func (*Tracker) ListSchemaTables ¶
ListSchemaTables lists all tables in the schema.
func (*Tracker) RemoveDownstreamSchema ¶
RemoveDownstreamSchema just remove schema or table in downstreamTrack.