export

package
v0.0.0-...-ef3476f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2020 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerTypeUnknown = iota
	ServerTypeMySQL
	ServerTypeMariaDB
	ServerTypeTiDB

	ServerTypeAll
)
View Source
const (
	UnspecifiedSize = 0
)

Variables

View Source
var ServerInfoUnknown = ServerInfo{
	ServerType:    ServerTypeUnknown,
	ServerVersion: nil,
}

Functions

func Dump

func Dump(conf *Config) (err error)

func FlushTableWithReadLock

func FlushTableWithReadLock(db *sql.DB) error

func GetColumnTypes

func GetColumnTypes(db *sql.DB, fields, database, table string) ([]*sql.ColumnType, error)

func GetPrimaryKeyName

func GetPrimaryKeyName(db *sql.DB, database, table string) (string, error)

func GetUniqueIndexName

func GetUniqueIndexName(db *sql.DB, database, table string) (string, error)

func ListAllTables

func ListAllTables(db *sql.DB, database string) ([]string, error)

func ListAllViews

func ListAllViews(db *sql.DB, database string) ([]string, error)

func LockTables

func LockTables(db *sql.DB, database, table string) error

func SelectTiDBRowID

func SelectTiDBRowID(db *sql.DB, database, table string) (bool, error)

func SelectVersion

func SelectVersion(db *sql.DB) (string, error)

func SetTiDBSnapshot

func SetTiDBSnapshot(db *sql.DB, snapshot string) error

func ShowCreateDatabase

func ShowCreateDatabase(db *sql.DB, database string) (string, error)

func ShowCreateTable

func ShowCreateTable(db *sql.DB, database, table string) (string, error)

func ShowCreateView

func ShowCreateView(db *sql.DB, database, view string) (string, error)

func ShowDatabases

func ShowDatabases(db *sql.DB) ([]string, error)

func ShowMasterStatus

func ShowMasterStatus(db *sql.DB, fieldNum int) ([]string, error)

func ShowTables

func ShowTables(db *sql.DB) ([]string, error)

ShowTables shows the tables of a database, the caller should use the correct database.

func UnlockTables

func UnlockTables(db *sql.DB) error

func UseDatabase

func UseDatabase(db *sql.DB, databaseName string) error

func WriteInsert

func WriteInsert(tblIR TableDataIR, w io.StringWriter) error

func WriteMeta

func WriteMeta(meta MetaIR, w io.StringWriter) error

Types

type BWList

type BWList interface {
	Apply(schema string, table string) bool
}

func NewBWList

func NewBWList(conf BWListConf) (BWList, error)

type BWListConf

type BWListConf struct {
	Mode BWListMode

	Rules *MySQLReplicationConf
}

type BWListMode

type BWListMode byte
const (
	NopMode BWListMode = 0x0
	// We have used this black and white list in pingcap/dm and pingcap/tidb-lightning project
	MySQLReplicationMode BWListMode = 0x1
)

type Config

type Config struct {
	Database string
	Host     string
	User     string
	Port     int
	Password string
	Threads  int

	FileSize      uint64
	StatementSize uint64
	OutputDirPath string
	ServerInfo    ServerInfo
	SortByPk      bool
	Tables        DatabaseTables
	StatusAddr    string
	Snapshot      string
	Consistency   string
	NoViews       bool

	BlackWhiteList  BWListConf
	Rows            uint64
	Where           string
	EscapeBackslash bool
}

func DefaultConfig

func DefaultConfig() *Config

type ConsistencyController

type ConsistencyController interface {
	Setup() error
	TearDown() error
}

func NewConsistencyController

func NewConsistencyController(conf *Config, session *sql.DB) (ConsistencyController, error)

type ConsistencyFlushTableWithReadLock

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

func (*ConsistencyFlushTableWithReadLock) Setup

func (*ConsistencyFlushTableWithReadLock) TearDown

type ConsistencyLockDumpingTables

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

func (*ConsistencyLockDumpingTables) Setup

func (*ConsistencyLockDumpingTables) TearDown

func (c *ConsistencyLockDumpingTables) TearDown() error

type ConsistencyNone

type ConsistencyNone struct{}

func (*ConsistencyNone) Setup

func (c *ConsistencyNone) Setup() error

func (*ConsistencyNone) TearDown

func (c *ConsistencyNone) TearDown() error

type ConsistencySnapshot

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

func (*ConsistencySnapshot) Setup

func (c *ConsistencySnapshot) Setup() error

func (*ConsistencySnapshot) TearDown

func (c *ConsistencySnapshot) TearDown() error

type DatabaseTables

type DatabaseTables map[databaseName][]*TableInfo

func NewDatabaseTables

func NewDatabaseTables() DatabaseTables

func (DatabaseTables) AppendTable

func (d DatabaseTables) AppendTable(dbName string, table *TableInfo) DatabaseTables

func (DatabaseTables) AppendTables

func (d DatabaseTables) AppendTables(dbName string, tableNames ...string) DatabaseTables

func (DatabaseTables) AppendViews

func (d DatabaseTables) AppendViews(dbName string, viewNames ...string) DatabaseTables

func (DatabaseTables) Literal

func (d DatabaseTables) Literal() string

func (DatabaseTables) Merge

func (d DatabaseTables) Merge(other DatabaseTables)

type InterceptStringWriter

type InterceptStringWriter struct {
	io.StringWriter
	SomethingIsWritten bool
}

InterceptStringWriter is an interceptor of io.StringWriter, tracking whether a StringWriter has written something.

func (*InterceptStringWriter) WriteString

func (w *InterceptStringWriter) WriteString(str string) (int, error)

type LazyStringWriter

type LazyStringWriter struct {
	sync.Once
	io.StringWriter
	// contains filtered or unexported fields
}

func (*LazyStringWriter) WriteString

func (l *LazyStringWriter) WriteString(str string) (int, error)

type Logger

type Logger interface {
	Debug(format string, args ...interface{})
	Info(format string, args ...interface{})
	Warn(format string, args ...interface{})
	Error(format string, args ...interface{})
}

Logger used for logging when export.

type MetaIR

type MetaIR interface {
	SpecialComments() StringIter
	TargetName() string
	MetaSQL() string
}

type MySQLReplicationBWList

type MySQLReplicationBWList struct {
	*filter.Filter
}

func (*MySQLReplicationBWList) Apply

func (bw *MySQLReplicationBWList) Apply(schema, table string) bool

type MySQLReplicationConf

type MySQLReplicationConf struct {
	Rules         *filter.Rules
	CaseSensitive bool
}

type NopeBWList

type NopeBWList struct{}

func (*NopeBWList) Apply

func (bw *NopeBWList) Apply(schema, table string) bool

type RowReceiver

type RowReceiver interface {
	BindAddress([]interface{})
	ReportSize() uint64
}

type RowReceiverArr

type RowReceiverArr []RowReceiverStringer

func (RowReceiverArr) BindAddress

func (r RowReceiverArr) BindAddress(args []interface{})

func (RowReceiverArr) ReportSize

func (r RowReceiverArr) ReportSize() uint64

func (RowReceiverArr) ToString

func (r RowReceiverArr) ToString() string

type RowReceiverStringer

type RowReceiverStringer interface {
	RowReceiver
	Stringer
}

func MakeRowReceiver

func MakeRowReceiver(colTypes []string) RowReceiverStringer

func SQLTypeBytesMaker

func SQLTypeBytesMaker() RowReceiverStringer

func SQLTypeNumberMaker

func SQLTypeNumberMaker() RowReceiverStringer

func SQLTypeStringMaker

func SQLTypeStringMaker() RowReceiverStringer

type SQLRowIter

type SQLRowIter interface {
	Next(RowReceiver) error
	HasNext() bool
	HasNextSQLRowIter() bool
	NextSQLRowIter() SQLRowIter
	// release SQLRowIter
	Close() error
}

SQLRowIter is the iterator on a collection of sql.Row.

type SQLTypeBytes

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

func (*SQLTypeBytes) BindAddress

func (s *SQLTypeBytes) BindAddress(arg []interface{})

func (*SQLTypeBytes) ReportSize

func (s *SQLTypeBytes) ReportSize() uint64

func (*SQLTypeBytes) ToString

func (s *SQLTypeBytes) ToString() string

type SQLTypeNumber

type SQLTypeNumber struct {
	SQLTypeString
}

func (SQLTypeNumber) ToString

func (s SQLTypeNumber) ToString() string

type SQLTypeString

type SQLTypeString struct {
	sql.NullString
}

func (*SQLTypeString) BindAddress

func (s *SQLTypeString) BindAddress(arg []interface{})

func (*SQLTypeString) ReportSize

func (s *SQLTypeString) ReportSize() uint64

func (*SQLTypeString) ToString

func (s *SQLTypeString) ToString() string

type ServerInfo

type ServerInfo struct {
	ServerType    ServerType
	ServerVersion *semver.Version
}

func ParseServerInfo

func ParseServerInfo(src string) ServerInfo

type ServerType

type ServerType int8

func (ServerType) String

func (s ServerType) String() string

type SimpleWriter

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

func (*SimpleWriter) WriteDatabaseMeta

func (f *SimpleWriter) WriteDatabaseMeta(ctx context.Context, db, createSQL string) error

func (*SimpleWriter) WriteTableData

func (f *SimpleWriter) WriteTableData(ctx context.Context, ir TableDataIR) error

func (*SimpleWriter) WriteTableMeta

func (f *SimpleWriter) WriteTableMeta(ctx context.Context, db, table, createSQL string) error

type StringIter

type StringIter interface {
	Next() string
	HasNext() bool
}

StringIter is the iterator on a collection of strings.

type Stringer

type Stringer interface {
	ToString() string
}

type TableDataIR

type TableDataIR interface {
	DatabaseName() string
	TableName() string
	ChunkIndex() int
	ColumnCount() uint
	ColumnTypes() []string
	SelectedField() string

	SpecialComments() StringIter
	Rows() SQLRowIter
}

TableDataIR is table data intermediate representation.

func SelectAllFromTable

func SelectAllFromTable(conf *Config, db *sql.DB, database, table string) (TableDataIR, error)

type TableInfo

type TableInfo struct {
	Name string
	Type TableType
}

func (*TableInfo) Equals

func (t *TableInfo) Equals(other *TableInfo) bool

type TableType

type TableType int8
const (
	TableTypeBase TableType = iota
	TableTypeView
)

type Writer

type Writer interface {
	WriteDatabaseMeta(ctx context.Context, db, createSQL string) error
	WriteTableMeta(ctx context.Context, db, table, createSQL string) error
	WriteTableData(ctx context.Context, ir TableDataIR) error
}

func NewSimpleWriter

func NewSimpleWriter(config *Config) (Writer, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL