Versions in this module Expand all Collapse all v7 v7.0.4 Jan 30, 2023 v7.0.2 Jan 30, 2023 v7.0.1 Jan 30, 2023 v7.0.0 Jan 30, 2023 Changes in this version + const ConsistencyTypeAuto + const ConsistencyTypeFlush + const ConsistencyTypeLock + const ConsistencyTypeNone + const ConsistencyTypeSnapshot + const DefaultAnonymousOutputFileTemplateText + const DefaultStatementSize + const DefaultTableFilter + const ErrNoSuchTable + const FileFormatCSVString + const FileFormatSQLTextString + const FlagHelp + const LooseCollationCompatible + const StrictCollationCompatible + const TableTypeBaseStr + const TableTypeSequenceStr + const TableTypeViewStr + const TiDBMemQuotaQueryName + const UnspecifiedSize + var DefaultOutputFileTemplate = template.Must(...(defaultOutputFileTemplateBase)) + var ServerInfoUnknown = version.ServerInfo + func AddCounter(counterVec *prometheus.CounterVec, v float64) + func AddGauge(gaugeVec *prometheus.GaugeVec, v float64) + func CheckIfSeqExists(db *sql.Conn) (bool, error) + func CheckTiDBEnableTableLock(db *sql.Conn) (bool, error) + func CheckTiDBWithTiKV(db *sql.DB) (bool, error) + func DatabaseTablesToMap(d DatabaseTables) map[string]map[string]struct + func DecGauge(gaugeVec *prometheus.GaugeVec) + func FlushTableWithReadLock(ctx context.Context, db *sql.Conn) error + func GetCharsetAndDefaultCollation(ctx context.Context, db *sql.Conn) (map[string]string, error) + func GetColumnTypes(tctx *tcontext.Context, db *BaseConn, fields, database, table string) ([]*sql.ColumnType, error) + func GetDBInfo(db *sql.Conn, tables map[string]map[string]struct{}) ([]*model.DBInfo, error) + func GetPartitionNames(tctx *tcontext.Context, db *BaseConn, schema, table string) (partitions []string, err error) + func GetPartitionTableIDs(db *sql.Conn, tables map[string]map[string]struct{}) (map[string]map[string]map[string]int64, error) + func GetPdAddrs(tctx *tcontext.Context, db *sql.DB) ([]string, error) + func GetPrimaryKeyAndColumnTypes(tctx *tcontext.Context, conn *BaseConn, meta TableMeta) ([]string, []string, error) + func GetPrimaryKeyColumns(tctx *tcontext.Context, db *BaseConn, database, table string) ([]string, error) + func GetRegionInfos(db *sql.Conn) (*helper.RegionsInfo, error) + func GetSpecifiedColumnValueAndClose(rows *sql.Rows, columnName string) ([]string, error) + func GetSpecifiedColumnValuesAndClose(rows *sql.Rows, columnName ...string) ([][]string, error) + func GetSuitableRows(avgRowLength uint64) uint64 + func GetTiDBDDLIDs(tctx *tcontext.Context, db *sql.DB) ([]string, error) + func IncCounter(counterVec *prometheus.CounterVec) + func IncGauge(gaugeVec *prometheus.GaugeVec) + func ListAllPlacementPolicyNames(tctx *tcontext.Context, db *BaseConn) ([]string, error) + func LockTables(ctx context.Context, db *sql.Conn, database, table string) error + func ObserveHistogram(histogramVec *prometheus.HistogramVec, v float64) + func ParseCompressType(compressType string) (storage.CompressType, error) + func ParseFileSize(fileSizeStr string) (uint64, error) + func ParseOutputFileTemplate(text string) (*template.Template, error) + func ParseTableFilter(tablesList, filters []string) (filter.Filter, error) + func ReadCounter(counterVec *prometheus.CounterVec) float64 + func ReadGauge(gaugeVec *prometheus.GaugeVec) float64 + func RestoreCharset(w io.StringWriter) + func SelectTiDBRowID(tctx *tcontext.Context, db *BaseConn, database, table string) (bool, error) + func SelectVersion(db *sql.DB) (string, error) + func SetCharset(w *strings.Builder, characterSet, collationConnection string) + func ShowCreateDatabase(tctx *tcontext.Context, db *BaseConn, database string) (string, error) + func ShowCreatePlacementPolicy(tctx *tcontext.Context, db *BaseConn, policy string) (string, error) + func ShowCreateSequence(tctx *tcontext.Context, db *BaseConn, database, sequence string, conf *Config) (string, error) + func ShowCreateTable(tctx *tcontext.Context, db *BaseConn, database, table string) (string, error) + func ShowCreateView(tctx *tcontext.Context, db *BaseConn, database, view string) (createFakeTableSQL string, createRealViewSQL string, err error) + func ShowDatabases(db *sql.Conn) ([]string, error) + func ShowMasterStatus(db *sql.Conn) ([]string, error) + func ShowTables(db *sql.Conn) ([]string, error) + func SubGauge(gaugeVec *prometheus.GaugeVec, v float64) + func UnlockTables(ctx context.Context, db *sql.Conn) error + func WriteInsert(pCtx *tcontext.Context, cfg *Config, meta TableMeta, tblIR TableDataIR, ...) (n uint64, err error) + func WriteInsertInCsv(pCtx *tcontext.Context, cfg *Config, meta TableMeta, tblIR TableDataIR, ...) (n uint64, err error) + func WriteMeta(tctx *tcontext.Context, meta MetaIR, w storage.ExternalFileWriter) error + type BaseConn struct + DBConn *sql.Conn + func (conn *BaseConn) ExecSQL(tctx *tcontext.Context, canRetryFunc func(sql.Result, error) error, ...) error + func (conn *BaseConn) QuerySQL(tctx *tcontext.Context, handleOneRow func(*sql.Rows) error, reset func(), ...) error + func (conn *BaseConn) QuerySQLWithColumns(tctx *tcontext.Context, columns []string, query string, args ...interface{}) ([][]string, error) + type Config struct + AllowCleartextPasswords bool + CollationCompatible string + CompleteInsert bool + CompressType storage.CompressType + Consistency string + CsvDelimiter string + CsvNullValue string + CsvSeparator string + Databases []string + DumpEmptyDatabase bool + EscapeBackslash bool + ExtStorage storage.ExternalStorage + FileSize uint64 + FileType string + Host string + IOTotalBytes *atomic.Uint64 + Labels prometheus.Labels + LogFile string + LogFormat string + LogLevel string + Logger *zap.Logger + Net string + NoData bool + NoHeader bool + NoSchemas bool + NoSequences bool + NoViews bool + OutputDirPath string + OutputFileTemplate *template.Template + Password string + Port int + PosAfterConnect bool + PromFactory promutil.Factory + PromRegistry promutil.Registry + ReadTimeout time.Duration + Rows uint64 + SQL string + Security struct{ ... } + ServerInfo version.ServerInfo + SessionParams map[string]interface{} + Snapshot string + SortByPk bool + StatementSize uint64 + StatusAddr string + TableFilter filter.Filter + Tables DatabaseTables + Threads int + TiDBMemQuotaQuery uint64 + TransactionalConsistency bool + User string + Where string + func DefaultConfig() *Config + func (*Config) DefineFlags(flags *pflag.FlagSet) + func (conf *Config) GetDriverConfig(db string) *mysql.Config + func (conf *Config) ParseFromFlags(flags *pflag.FlagSet) error + func (conf *Config) String() string + type ConsistencyController interface + PingContext func(context.Context) error + Setup func(*tcontext.Context) error + TearDown func(context.Context) error + func NewConsistencyController(ctx context.Context, conf *Config, session *sql.DB) (ConsistencyController, error) + type ConsistencyFlushTableWithReadLock struct + func (c *ConsistencyFlushTableWithReadLock) PingContext(ctx context.Context) error + func (c *ConsistencyFlushTableWithReadLock) Setup(tctx *tcontext.Context) error + func (c *ConsistencyFlushTableWithReadLock) TearDown(ctx context.Context) error + type ConsistencyLockDumpingTables struct + func (c *ConsistencyLockDumpingTables) PingContext(ctx context.Context) error + func (c *ConsistencyLockDumpingTables) Setup(tctx *tcontext.Context) error + func (c *ConsistencyLockDumpingTables) TearDown(ctx context.Context) error + type ConsistencyNone struct + func (*ConsistencyNone) PingContext(_ context.Context) error + func (*ConsistencyNone) Setup(_ *tcontext.Context) error + func (*ConsistencyNone) TearDown(_ context.Context) error + type DatabaseTables map[databaseName][]*TableInfo + func GetConfTables(tablesList []string) (DatabaseTables, error) + func ListAllDatabasesTables(tctx *tcontext.Context, db *sql.Conn, databaseNames []string, ...) (DatabaseTables, error) + func NewDatabaseTables() DatabaseTables + func (d DatabaseTables) AppendTable(dbName string, table *TableInfo) DatabaseTables + func (d DatabaseTables) AppendTables(dbName string, tableNames []string, avgRowLengths []uint64) DatabaseTables + func (d DatabaseTables) AppendViews(dbName string, viewNames ...string) DatabaseTables + func (d DatabaseTables) Literal() string + func (d DatabaseTables) Merge(other DatabaseTables) + type DumpStatus struct + CompletedTables float64 + CurrentSpeedBPS float64 + EstimateTotalRows float64 + FinishedBytes float64 + FinishedRows float64 + Progress string + TotalTables int64 + type Dumper struct + func NewDumper(ctx context.Context, conf *Config) (*Dumper, error) + func (d *Dumper) Close() error + func (d *Dumper) Dump() (dumpErr error) + func (d *Dumper) GetStatus() *DumpStatus + func (d *Dumper) L() log.Logger + type FileFormat int32 + const FileFormatCSV + const FileFormatSQLText + const FileFormatUnknown + func (f FileFormat) Extension() string + func (f FileFormat) String() string + func (f FileFormat) WriteInsert(pCtx *tcontext.Context, cfg *Config, meta TableMeta, tblIR TableDataIR, ...) (uint64, error) + type InterceptFileWriter struct + SomethingIsWritten bool + func (w *InterceptFileWriter) Close(ctx context.Context) error + func (w *InterceptFileWriter) Write(ctx context.Context, p []byte) (int, error) + type LazyStringWriter struct + func (l *LazyStringWriter) WriteString(str string) (int, error) + type MetaIR interface + MetaSQL func() string + SpecialComments func() StringIter + TargetName func() string + type RowReceiver interface + BindAddress func([]interface{}) + type RowReceiverArr struct + func MakeRowReceiver(colTypes []string) RowReceiverArr + func (r RowReceiverArr) BindAddress(args []interface{}) + func (r RowReceiverArr) WriteToBuffer(bf *bytes.Buffer, escapeBackslash bool) + func (r RowReceiverArr) WriteToBufferInCsv(bf *bytes.Buffer, escapeBackslash bool, opt *csvOption) + type RowReceiverStringer interface + func SQLTypeBytesMaker() RowReceiverStringer + func SQLTypeNumberMaker() RowReceiverStringer + func SQLTypeStringMaker() RowReceiverStringer + type SQLRowIter interface + Close func() error + Decode func(RowReceiver) error + Error func() error + HasNext func() bool + Next func() + type SQLTypeBytes struct + func (s *SQLTypeBytes) BindAddress(arg []interface{}) + func (s *SQLTypeBytes) WriteToBuffer(bf *bytes.Buffer, _ bool) + func (s *SQLTypeBytes) WriteToBufferInCsv(bf *bytes.Buffer, escapeBackslash bool, opt *csvOption) + type SQLTypeNumber struct + func (s SQLTypeNumber) WriteToBuffer(bf *bytes.Buffer, _ bool) + func (s SQLTypeNumber) WriteToBufferInCsv(bf *bytes.Buffer, _ bool, opt *csvOption) + type SQLTypeString struct + func (s *SQLTypeString) BindAddress(arg []interface{}) + func (s *SQLTypeString) WriteToBuffer(bf *bytes.Buffer, escapeBackslash bool) + func (s *SQLTypeString) WriteToBufferInCsv(bf *bytes.Buffer, escapeBackslash bool, opt *csvOption) + type SpeedRecorder struct + func NewSpeedRecorder() *SpeedRecorder + func (s *SpeedRecorder) GetSpeed(finished float64) float64 + type StringIter interface + HasNext func() bool + Next func() string + type Stringer interface + WriteToBuffer func(*bytes.Buffer, bool) + WriteToBufferInCsv func(*bytes.Buffer, bool, *csvOption) + type TableDataIR interface + Close func() error + RawRows func() *sql.Rows + Rows func() SQLRowIter + Start func(*tcontext.Context, *sql.Conn) error + func SelectAllFromTable(conf *Config, meta TableMeta, partition, orderByClause string) TableDataIR + type TableInfo struct + AvgRowLength uint64 + Name string + Type TableType + func (t *TableInfo) Equals(other *TableInfo) bool + type TableMeta interface + AvgRowLength func() uint64 + ColumnCount func() uint + ColumnNames func() []string + ColumnTypes func() []string + DatabaseName func() string + HasImplicitRowID func() bool + SelectedField func() string + SelectedLen func() int + ShowCreateTable func() string + ShowCreateView func() string + SpecialComments func() StringIter + TableName func() string + type TableType int8 + const TableTypeBase + const TableTypeSequence + const TableTypeView + func ParseTableType(s string) (TableType, error) + func (t TableType) String() string + type Task interface + Brief func() string + type TaskDatabaseMeta struct + CreateDatabaseSQL string + DatabaseName string + func NewTaskDatabaseMeta(dbName, createSQL string) *TaskDatabaseMeta + func (t *TaskDatabaseMeta) Brief() string + type TaskPolicyMeta struct + CreatePolicySQL string + PolicyName string + func NewTaskPolicyMeta(policyName, createPolicySQL string) *TaskPolicyMeta + func (t *TaskPolicyMeta) Brief() string + type TaskSequenceMeta struct + CreateSequenceSQL string + DatabaseName string + SequenceName string + func NewTaskSequenceMeta(dbName, tblName, createSequenceSQL string) *TaskSequenceMeta + func (t *TaskSequenceMeta) Brief() string + type TaskTableData struct + ChunkIndex int + Data TableDataIR + Meta TableMeta + TotalChunks int + func NewTaskTableData(meta TableMeta, data TableDataIR, currentChunk, totalChunks int) *TaskTableData + func (t *TaskTableData) Brief() string + type TaskTableMeta struct + CreateTableSQL string + DatabaseName string + TableName string + func NewTaskTableMeta(dbName, tblName, createSQL string) *TaskTableMeta + func (t *TaskTableMeta) Brief() string + type TaskViewMeta struct + CreateTableSQL string + CreateViewSQL string + DatabaseName string + ViewName string + func NewTaskViewMeta(dbName, tblName, createTableSQL, createViewSQL string) *TaskViewMeta + func (t *TaskViewMeta) Brief() string + type Writer struct + func NewWriter(tctx *tcontext.Context, id int64, config *Config, conn *sql.Conn, ...) *Writer + func (w *Writer) WriteDatabaseMeta(db, createSQL string) error + func (w *Writer) WritePolicyMeta(policy, createSQL string) error + func (w *Writer) WriteSequenceMeta(db, sequence, createSQL string) error + func (w *Writer) WriteTableData(meta TableMeta, ir TableDataIR, currentChunk int) error + func (w *Writer) WriteTableMeta(db, table, createSQL string) error + func (w *Writer) WriteViewMeta(db, view, createTableSQL, createViewSQL string) error