Versions in this module Expand all Collapse all v4 v4.1.1 Jan 18, 2024 Changes in this version + const DefaultAnonymousOutputFileTemplateText + const DefaultStatementSize + const DefaultTableFilter + const ErrNoSuchTable + const FileFormatCSVString + const FileFormatSQLTextString + const FlagHelp + const ServerTypeAll + const ServerTypeMariaDB + const ServerTypeMySQL + const ServerTypeTiDB + const ServerTypeUnknown + const TableTypeBaseStr + const TableTypeViewStr + const TiDBMemQuotaQueryName + const UnspecifiedSize + var DefaultOutputFileTemplate = template.Must(...(defaultOutputFileTemplateBase)) + var ServerInfoUnknown = ServerInfo + func AddCounter(counterVec *prometheus.CounterVec, labels prometheus.Labels, v float64) + func AddGauge(gaugeVec *prometheus.GaugeVec, labels prometheus.Labels, v float64) + func CheckTiDBWithTiKV(db *sql.DB) (bool, error) + func DatabaseTablesToMap(d DatabaseTables) map[string]map[string]struct + func DecGauge(gaugeVec *prometheus.GaugeVec, labels prometheus.Labels) + func FlushTableWithReadLock(ctx context.Context, db *sql.Conn) error + func GetColumnTypes(db *sql.Conn, fields, database, table string) ([]*sql.ColumnType, error) + func GetDBInfo(db *sql.Conn, tables map[string]map[string]struct{}) ([]*model.DBInfo, error) + func GetPartitionNames(db *sql.Conn, 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(conn *sql.Conn, meta TableMeta) ([]string, []string, error) + func GetPrimaryKeyColumns(db *sql.Conn, 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, labels prometheus.Labels) + func IncGauge(gaugeVec *prometheus.GaugeVec, labels prometheus.Labels) + func InitMetricsVector(labels prometheus.Labels) + func LockTables(ctx context.Context, db *sql.Conn, database, table string) error + func ObserveHistogram(histogramVec *prometheus.HistogramVec, labels prometheus.Labels, 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, labels prometheus.Labels) float64 + func ReadGauge(gaugeVec *prometheus.GaugeVec, labels prometheus.Labels) float64 + func RegisterMetrics(registry *prometheus.Registry) + func RemoveLabelValuesWithTaskInMetrics(labels prometheus.Labels) + func RestoreCharset(w io.StringWriter) + func SelectTiDBRowID(db *sql.Conn, database, table string) (bool, error) + func SelectVersion(db *sql.DB) (string, error) + func SetCharset(w *strings.Builder, characterSet, collationConnection string) + func ShowCreateDatabase(db *sql.Conn, database string) (string, error) + func ShowCreateTable(db *sql.Conn, database, table string) (string, error) + func ShowCreateView(db *sql.Conn, 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, labels prometheus.Labels, 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 Config struct + AllowCleartextPasswords bool + CompleteInsert bool + CompressType storage.CompressType + Consistency string + CsvDelimiter string + CsvNullValue string + CsvSeparator string + Databases []string + DumpEmptyDatabase bool + EscapeBackslash bool + FileSize uint64 + FileType string + Host string + Labels prometheus.Labels + LogFile string + LogFormat string + LogLevel string + Logger *zap.Logger + NoData bool + NoHeader bool + NoSchemas bool + NoViews bool + OutputDirPath string + OutputFileTemplate *template.Template + Password string + Port int + PosAfterConnect bool + ReadTimeout time.Duration + Rows uint64 + SQL string + Security struct{ ... } + ServerInfo 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 (conf *Config) DefineFlags(flags *pflag.FlagSet) + func (conf *Config) GetDSN(db string) string + 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 (c *ConsistencyNone) PingContext(_ context.Context) error + func (c *ConsistencyNone) Setup(_ *tcontext.Context) error + func (c *ConsistencyNone) TearDown(_ context.Context) error + type DatabaseTables map[databaseName][]*TableInfo + 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 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) 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 ServerInfo struct + HasTiKV bool + ServerType ServerType + ServerVersion *semver.Version + func ParseServerInfo(tctx *tcontext.Context, src string) ServerInfo + type ServerType int8 + func (s ServerType) String() string + 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 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 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) 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 Other modules containing this package github.com/dbakit/dumpling/v5