Documentation ¶
Index ¶
- Constants
- Variables
- 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
- 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
- type ConsistencyController
- type ConsistencyFlushTableWithReadLock
- type ConsistencyLockDumpingTables
- type ConsistencyNone
- type 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
- type Dumper
- type FileFormat
- type InterceptFileWriter
- type LazyStringWriter
- type MetaIR
- type RowReceiver
- type RowReceiverArr
- type RowReceiverStringer
- type SQLRowIter
- type SQLTypeBytes
- type SQLTypeNumber
- type SQLTypeString
- type SpeedRecorder
- type StringIter
- type Stringer
- type TableDataIR
- type TableInfo
- type TableMeta
- type TableType
- type Task
- type TaskDatabaseMeta
- type TaskPolicyMeta
- type TaskSequenceMeta
- type TaskTableData
- type TaskTableMeta
- type TaskViewMeta
- type 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
Constants ¶
const ( // UnspecifiedSize means the filesize/statement-size is unspecified UnspecifiedSize = 0 // DefaultStatementSize is the default statement size DefaultStatementSize = 1000000 // TiDBMemQuotaQueryName is the session variable TiDBMemQuotaQuery's name in TiDB TiDBMemQuotaQueryName = "tidb_mem_quota_query" // DefaultTableFilter is the default exclude table filter. It will exclude all system databases DefaultTableFilter = "!/^(mysql|sys|INFORMATION_SCHEMA|PERFORMANCE_SCHEMA|METRICS_SCHEMA|INSPECTION_SCHEMA)$/.*" // LooseCollationCompatible is used in DM, represents a collation setting for best compatibility. LooseCollationCompatible = "loose" // StrictCollationCompatible is used in DM, represents a collation setting for correctness. StrictCollationCompatible = "strict" )
const ( // ConsistencyTypeAuto will use flush for MySQL/MariaDB and snapshot for TiDB. ConsistencyTypeAuto = "auto" // ConsistencyTypeFlush will use FLUSH TABLES WITH READ LOCK to temporarily interrupt the DML and DDL operations of the replica database, // to ensure the global consistency of the backup connection. ConsistencyTypeFlush = "flush" // ConsistencyTypeLock will add read locks on all tables to be exported. ConsistencyTypeLock = "lock" // ConsistencyTypeSnapshot gets a consistent snapshot of the specified timestamp and exports it. ConsistencyTypeSnapshot = "snapshot" // ConsistencyTypeNone doesn't guarantee for consistency. ConsistencyTypeNone = "none" )
const ( // TableTypeBaseStr represents the basic table string TableTypeBaseStr = "BASE TABLE" // TableTypeViewStr represents the view table string TableTypeViewStr = "VIEW" // TableTypeSequenceStr represents the view table string TableTypeSequenceStr = "SEQUENCE" )
const ( // FileFormatSQLTextString indicates the string/suffix of sql type file FileFormatSQLTextString = "sql" // FileFormatCSVString indicates the string/suffix of csv type file FileFormatCSVString = "csv" )
const (
// DefaultAnonymousOutputFileTemplateText is the default anonymous output file templateText for dumpling's table data file name
DefaultAnonymousOutputFileTemplateText = "result.{{.Index}}"
)
const ( // ErrNoSuchTable is the error code no such table in MySQL/TiDB ErrNoSuchTable uint16 = 1146 )
const (
// FlagHelp represents the help flag
FlagHelp = "help"
)
Variables ¶
var ( // DefaultOutputFileTemplate is the default output file template for dumpling's table data file name DefaultOutputFileTemplate = template.Must(template.New("data"). Option("missingkey=error"). Funcs(template.FuncMap{ "fn": func(input string) string { return filenameEscapeRegexp.ReplaceAllStringFunc(input, func(match string) string { return fmt.Sprintf("%%%02X%s", match[0], match[1:]) }) }, }). Parse(defaultOutputFileTemplateBase)) )
var ServerInfoUnknown = version.ServerInfo{ ServerType: version.ServerTypeUnknown, ServerVersion: nil, }
ServerInfoUnknown is the unknown database type to dumpling
Functions ¶
func AddCounter ¶
func AddCounter(counterVec *prometheus.CounterVec, v float64)
AddCounter adds a counter.
func CheckIfSeqExists ¶
CheckIfSeqExists use sql to check whether sequence exists
func CheckTiDBEnableTableLock ¶
CheckTiDBEnableTableLock use sql variable to check whether current TiDB has TiKV
func CheckTiDBWithTiKV ¶
CheckTiDBWithTiKV use sql to check whether current TiDB has TiKV
func DatabaseTablesToMap ¶
func DatabaseTablesToMap(d DatabaseTables) map[string]map[string]struct{}
DatabaseTablesToMap transfers DatabaseTables to Map
func FlushTableWithReadLock ¶
FlushTableWithReadLock flush tables with read lock
func GetCharsetAndDefaultCollation ¶
GetCharsetAndDefaultCollation gets charset and default collation map.
func GetColumnTypes ¶
func GetColumnTypes(tctx *tcontext.Context, db *BaseConn, fields, database, table string) ([]*sql.ColumnType, error)
GetColumnTypes gets *sql.ColumnTypes from a specified table
func GetDBInfo ¶
GetDBInfo get model.DBInfos from database sql interface. We need table_id to check whether a region belongs to this table
func GetPartitionNames ¶
func GetPartitionNames(tctx *tcontext.Context, db *BaseConn, schema, table string) (partitions []string, err error)
GetPartitionNames get partition names from a specified table
func GetPartitionTableIDs ¶
func GetPartitionTableIDs(db *sql.Conn, tables map[string]map[string]struct{}) (map[string]map[string]map[string]int64, error)
GetPartitionTableIDs get partition tableIDs through histograms. SHOW STATS_HISTOGRAMS has db_name,table_name,partition_name but doesn't have partition id mysql.stats_histograms has partition_id but doesn't have db_name,table_name,partition_name So we combine the results from these two sqls to get partition ids for each table If UPDATE_TIME,DISTINCT_COUNT are equal, we assume these two records can represent one line. If histograms are not accurate or (UPDATE_TIME,DISTINCT_COUNT) has duplicate data, it's still fine. Because the possibility is low and the effect is that we will select more than one regions in one time, this will not affect the correctness of the dumping data and will not affect the memory usage much. This method is tricky, but no better way is found. Because TiDB v3.0.0's information_schema.partition table doesn't have partition name or partition id info return (dbName -> tbName -> partitionName -> partitionID, error)
func GetPdAddrs ¶
GetPdAddrs gets PD address from TiDB
func GetPrimaryKeyAndColumnTypes ¶
func GetPrimaryKeyAndColumnTypes(tctx *tcontext.Context, conn *BaseConn, meta TableMeta) ([]string, []string, error)
GetPrimaryKeyAndColumnTypes gets all primary columns and their types in ordinal order
func GetPrimaryKeyColumns ¶
func GetPrimaryKeyColumns(tctx *tcontext.Context, db *BaseConn, database, table string) ([]string, error)
GetPrimaryKeyColumns gets all primary columns in ordinal order
func GetRegionInfos ¶
func GetRegionInfos(db *sql.Conn) (*helper.RegionsInfo, error)
GetRegionInfos get region info including regionID, start key, end key from database sql interface. start key, end key includes information to help split table
func GetSpecifiedColumnValueAndClose ¶
GetSpecifiedColumnValueAndClose get columns' values whose name is equal to columnName and close the given rows
func GetSpecifiedColumnValuesAndClose ¶
GetSpecifiedColumnValuesAndClose get columns' values whose name is equal to columnName
func GetSuitableRows ¶
GetSuitableRows gets suitable rows for each table
func GetTiDBDDLIDs ¶
GetTiDBDDLIDs gets DDL IDs from TiDB
func ListAllPlacementPolicyNames ¶
ListAllPlacementPolicyNames returns all placement policy names.
func LockTables ¶
LockTables locks table with read lock
func ObserveHistogram ¶
func ObserveHistogram(histogramVec *prometheus.HistogramVec, v float64)
ObserveHistogram observes a histogram
func ParseCompressType ¶
func ParseCompressType(compressType string) (storage.CompressType, error)
ParseCompressType parses compressType string to storage.CompressType
func ParseFileSize ¶
ParseFileSize parses file size from tables-list and filter arguments
func ParseOutputFileTemplate ¶
ParseOutputFileTemplate parses template from the specified text
func ParseTableFilter ¶
ParseTableFilter parses table filter from tables-list and filter arguments
func ReadCounter ¶
func ReadCounter(counterVec *prometheus.CounterVec) float64
ReadCounter reports the current value of the counter.
func ReadGauge ¶
func ReadGauge(gaugeVec *prometheus.GaugeVec) float64
ReadGauge reports the current value of the gauge.
func RestoreCharset ¶
func RestoreCharset(w io.StringWriter)
RestoreCharset builds the restore charset SQLs
func SelectTiDBRowID ¶
SelectTiDBRowID checks whether this table has _tidb_rowid column
func SelectVersion ¶
SelectVersion gets the version information from the database server
func SetCharset ¶
SetCharset builds the set charset SQLs
func ShowCreateDatabase ¶
ShowCreateDatabase constructs the create database SQL for a specified database returns (createDatabaseSQL, error)
func ShowCreatePlacementPolicy ¶
ShowCreatePlacementPolicy constructs the create policy SQL for a specified table returns (createPolicySQL, error)
func ShowCreateSequence ¶
func ShowCreateSequence(tctx *tcontext.Context, db *BaseConn, database, sequence string, conf *Config) (string, error)
ShowCreateSequence constructs the create sequence SQL for a specified sequence returns (createSequenceSQL, error)
func ShowCreateTable ¶
ShowCreateTable constructs the create table SQL for a specified table returns (createTableSQL, error)
func ShowCreateView ¶
func ShowCreateView(tctx *tcontext.Context, db *BaseConn, database, view string) (createFakeTableSQL string, createRealViewSQL string, err error)
ShowCreateView constructs the create view SQL for a specified view returns (createFakeTableSQL, createViewSQL, error)
func ShowDatabases ¶
ShowDatabases shows the databases of a database server.
func ShowMasterStatus ¶
ShowMasterStatus get SHOW MASTER STATUS result from database
func ShowTables ¶
ShowTables shows the tables of a database, the caller should use the correct database.
func UnlockTables ¶
UnlockTables unlocks all tables' lock
func WriteInsert ¶
func WriteInsert( pCtx *tcontext.Context, cfg *Config, meta TableMeta, tblIR TableDataIR, w storage.ExternalFileWriter, metrics *metrics, ) (n uint64, err error)
WriteInsert writes TableDataIR to a storage.ExternalFileWriter in sql type
func WriteInsertInCsv ¶
func WriteInsertInCsv( pCtx *tcontext.Context, cfg *Config, meta TableMeta, tblIR TableDataIR, w storage.ExternalFileWriter, metrics *metrics, ) (n uint64, err error)
WriteInsertInCsv writes TableDataIR to a storage.ExternalFileWriter in csv type
Types ¶
type BaseConn ¶
BaseConn wraps connection instance.
func (*BaseConn) ExecSQL ¶
func (conn *BaseConn) ExecSQL(tctx *tcontext.Context, canRetryFunc func(sql.Result, error) error, query string, args ...interface{}) error
ExecSQL defines exec statement, and connect to real DB.
type Config ¶
type Config struct { storage.BackendOptions AllowCleartextPasswords bool SortByPk bool NoViews bool NoSequences bool NoHeader bool NoSchemas bool NoData bool CompleteInsert bool TransactionalConsistency bool EscapeBackslash bool DumpEmptyDatabase bool PosAfterConnect bool CompressType storage.CompressType Host string Port int Threads int User string Password string `json:"-"` Security struct { TLS *tls.Config `json:"-"` CAPath string CertPath string KeyPath string SSLCABytes []byte `json:"-"` SSLCertBytes []byte `json:"-"` SSLKeyBytes []byte `json:"-"` } LogLevel string LogFile string LogFormat string OutputDirPath string StatusAddr string Snapshot string Consistency string CsvNullValue string SQL string CsvSeparator string CsvDelimiter string Databases []string TableFilter filter.Filter `json:"-"` Where string FileType string ServerInfo version.ServerInfo Logger *zap.Logger `json:"-"` OutputFileTemplate *template.Template `json:"-"` Rows uint64 ReadTimeout time.Duration TiDBMemQuotaQuery uint64 FileSize uint64 StatementSize uint64 SessionParams map[string]interface{} Tables DatabaseTables CollationCompatible string Labels prometheus.Labels `json:"-"` PromFactory promutil.Factory `json:"-"` PromRegistry promutil.Registry `json:"-"` ExtStorage storage.ExternalStorage `json:"-"` IOTotalBytes *atomic.Uint64 Net string // contains filtered or unexported fields }
Config is the dump config for dumpling
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default export Config for dumpling
func (*Config) DefineFlags ¶
DefineFlags defines flags of dumpling's configuration
func (*Config) GetDriverConfig ¶
GetDriverConfig returns the MySQL driver config from Config.
func (*Config) ParseFromFlags ¶
ParseFromFlags parses dumpling's export.Config from flags nolint: gocyclo
type ConsistencyController ¶
type ConsistencyController interface { Setup(*tcontext.Context) error TearDown(context.Context) error PingContext(context.Context) error }
ConsistencyController is the interface that controls the consistency of exporting progress
func NewConsistencyController ¶
func NewConsistencyController(ctx context.Context, conf *Config, session *sql.DB) (ConsistencyController, error)
NewConsistencyController returns a new consistency controller
type ConsistencyFlushTableWithReadLock ¶
type ConsistencyFlushTableWithReadLock struct {
// contains filtered or unexported fields
}
ConsistencyFlushTableWithReadLock uses FlushTableWithReadLock before the dump
func (*ConsistencyFlushTableWithReadLock) PingContext ¶
func (c *ConsistencyFlushTableWithReadLock) PingContext(ctx context.Context) error
PingContext implements ConsistencyController.PingContext
type ConsistencyLockDumpingTables ¶
type ConsistencyLockDumpingTables struct {
// contains filtered or unexported fields
}
ConsistencyLockDumpingTables execute lock tables read on all tables before dump
func (*ConsistencyLockDumpingTables) PingContext ¶
func (c *ConsistencyLockDumpingTables) PingContext(ctx context.Context) error
PingContext implements ConsistencyController.PingContext
type ConsistencyNone ¶
type ConsistencyNone struct{}
ConsistencyNone dumps without adding locks, which cannot guarantee consistency
func (*ConsistencyNone) PingContext ¶
func (*ConsistencyNone) PingContext(_ context.Context) error
PingContext implements ConsistencyController.PingContext
type DatabaseTables ¶
type DatabaseTables map[databaseName][]*TableInfo
DatabaseTables is the type that represents tables in a database
func GetConfTables ¶
func GetConfTables(tablesList []string) (DatabaseTables, error)
GetConfTables parses tables from tables-list and filter arguments
func ListAllDatabasesTables ¶
func ListAllDatabasesTables(tctx *tcontext.Context, db *sql.Conn, databaseNames []string, listType listTableType, tableTypes ...TableType) (DatabaseTables, error)
ListAllDatabasesTables lists all the databases and tables from the database listTableByInfoSchema list tables by table information_schema in MySQL listTableByShowTableStatus has better performance than listTableByInfoSchema listTableByShowFullTables is used in mysql8 version [8.0.3,8.0.23), more details can be found in the comments of func matchMysqlBugversion
func NewDatabaseTables ¶
func NewDatabaseTables() DatabaseTables
NewDatabaseTables returns a new DatabaseTables
func (DatabaseTables) AppendTable ¶
func (d DatabaseTables) AppendTable(dbName string, table *TableInfo) DatabaseTables
AppendTable appends a TableInfo to DatabaseTables
func (DatabaseTables) AppendTables ¶
func (d DatabaseTables) AppendTables(dbName string, tableNames []string, avgRowLengths []uint64) DatabaseTables
AppendTables appends several basic tables to DatabaseTables
func (DatabaseTables) AppendViews ¶
func (d DatabaseTables) AppendViews(dbName string, viewNames ...string) DatabaseTables
AppendViews appends several views to DatabaseTables
func (DatabaseTables) Literal ¶
func (d DatabaseTables) Literal() string
Literal returns a user-friendly output for DatabaseTables
func (DatabaseTables) Merge ¶
func (d DatabaseTables) Merge(other DatabaseTables)
Merge merges another DatabaseTables
type DumpStatus ¶
type DumpStatus struct { CompletedTables float64 FinishedBytes float64 FinishedRows float64 EstimateTotalRows float64 TotalTables int64 CurrentSpeedBPS float64 Progress string }
DumpStatus is the status of dumping.
type Dumper ¶
type Dumper struct {
// contains filtered or unexported fields
}
Dumper is the dump progress structure
func (*Dumper) GetStatus ¶
func (d *Dumper) GetStatus() *DumpStatus
GetStatus returns the status of dumping by reading metrics.
type FileFormat ¶
type FileFormat int32
FileFormat is the format that output to file. Currently we support SQL text and CSV file format.
const ( // FileFormatUnknown indicates the given file type is unknown FileFormatUnknown FileFormat = iota // FileFormatSQLText indicates the given file type is sql type FileFormatSQLText // FileFormatCSV indicates the given file type is csv type FileFormatCSV )
func (FileFormat) Extension ¶
func (f FileFormat) Extension() string
Extension returns the extension for specific format.
text -> "sql" csv -> "csv"
func (FileFormat) String ¶
func (f FileFormat) String() string
String implement Stringer.String method.
func (FileFormat) WriteInsert ¶
func (f FileFormat) WriteInsert( pCtx *tcontext.Context, cfg *Config, meta TableMeta, tblIR TableDataIR, w storage.ExternalFileWriter, metrics *metrics, ) (uint64, error)
WriteInsert writes TableDataIR to a storage.ExternalFileWriter in sql/csv type
type InterceptFileWriter ¶
type InterceptFileWriter struct { storage.ExternalFileWriter sync.Once SomethingIsWritten bool // contains filtered or unexported fields }
InterceptFileWriter is an interceptor of os.File, tracking whether a StringWriter has written something.
type LazyStringWriter ¶
type LazyStringWriter struct { sync.Once io.StringWriter // contains filtered or unexported fields }
LazyStringWriter is an interceptor of io.StringWriter, will lazily create file the first time StringWriter need to write something.
func (*LazyStringWriter) WriteString ¶
func (l *LazyStringWriter) WriteString(str string) (int, error)
WriteString implements io.StringWriter. It check whether writer has written something and init a file at first time
type MetaIR ¶
type MetaIR interface { SpecialComments() StringIter TargetName() string MetaSQL() string }
MetaIR is the interface that wraps database/table/view's metadata
type RowReceiver ¶
type RowReceiver interface {
BindAddress([]interface{})
}
RowReceiver is an interface which represents sql types that support bind address for *sql.Rows
type RowReceiverArr ¶
type RowReceiverArr struct {
// contains filtered or unexported fields
}
RowReceiverArr is the combined RowReceiver array
func MakeRowReceiver ¶
func MakeRowReceiver(colTypes []string) RowReceiverArr
MakeRowReceiver constructs RowReceiverArr from column types
func (RowReceiverArr) BindAddress ¶
func (r RowReceiverArr) BindAddress(args []interface{})
BindAddress implements RowReceiver.BindAddress
func (RowReceiverArr) WriteToBuffer ¶
func (r RowReceiverArr) WriteToBuffer(bf *bytes.Buffer, escapeBackslash bool)
WriteToBuffer implements Stringer.WriteToBuffer
func (RowReceiverArr) WriteToBufferInCsv ¶
func (r RowReceiverArr) WriteToBufferInCsv(bf *bytes.Buffer, escapeBackslash bool, opt *csvOption)
WriteToBufferInCsv implements Stringer.WriteToBufferInCsv
type RowReceiverStringer ¶
type RowReceiverStringer interface { RowReceiver Stringer }
RowReceiverStringer is a combined interface of RowReceiver and Stringer
func SQLTypeBytesMaker ¶
func SQLTypeBytesMaker() RowReceiverStringer
SQLTypeBytesMaker returns a SQLTypeBytes
func SQLTypeNumberMaker ¶
func SQLTypeNumberMaker() RowReceiverStringer
SQLTypeNumberMaker returns a SQLTypeNumber
func SQLTypeStringMaker ¶
func SQLTypeStringMaker() RowReceiverStringer
SQLTypeStringMaker returns a SQLTypeString
type SQLRowIter ¶
type SQLRowIter interface { Decode(RowReceiver) error Next() Error() error HasNext() bool // release SQLRowIter Close() error }
SQLRowIter is the iterator on a collection of sql.Row.
type SQLTypeBytes ¶
SQLTypeBytes implements RowReceiverStringer which represents bytes type columns in database
func (*SQLTypeBytes) BindAddress ¶
func (s *SQLTypeBytes) BindAddress(arg []interface{})
BindAddress implements RowReceiver.BindAddress
func (*SQLTypeBytes) WriteToBuffer ¶
func (s *SQLTypeBytes) WriteToBuffer(bf *bytes.Buffer, _ bool)
WriteToBuffer implements Stringer.WriteToBuffer
func (*SQLTypeBytes) WriteToBufferInCsv ¶
func (s *SQLTypeBytes) WriteToBufferInCsv(bf *bytes.Buffer, escapeBackslash bool, opt *csvOption)
WriteToBufferInCsv implements Stringer.WriteToBufferInCsv
type SQLTypeNumber ¶
type SQLTypeNumber struct {
SQLTypeString
}
SQLTypeNumber implements RowReceiverStringer which represents numeric type columns in database
func (SQLTypeNumber) WriteToBuffer ¶
func (s SQLTypeNumber) WriteToBuffer(bf *bytes.Buffer, _ bool)
WriteToBuffer implements Stringer.WriteToBuffer
func (SQLTypeNumber) WriteToBufferInCsv ¶
func (s SQLTypeNumber) WriteToBufferInCsv(bf *bytes.Buffer, _ bool, opt *csvOption)
WriteToBufferInCsv implements Stringer.WriteToBufferInCsv
type SQLTypeString ¶
SQLTypeString implements RowReceiverStringer which represents string type columns in database
func (*SQLTypeString) BindAddress ¶
func (s *SQLTypeString) BindAddress(arg []interface{})
BindAddress implements RowReceiver.BindAddress
func (*SQLTypeString) WriteToBuffer ¶
func (s *SQLTypeString) WriteToBuffer(bf *bytes.Buffer, escapeBackslash bool)
WriteToBuffer implements Stringer.WriteToBuffer
func (*SQLTypeString) WriteToBufferInCsv ¶
func (s *SQLTypeString) WriteToBufferInCsv(bf *bytes.Buffer, escapeBackslash bool, opt *csvOption)
WriteToBufferInCsv implements Stringer.WriteToBufferInCsv
type SpeedRecorder ¶
type SpeedRecorder struct {
// contains filtered or unexported fields
}
SpeedRecorder record the finished bytes and calculate its speed.
func NewSpeedRecorder ¶
func NewSpeedRecorder() *SpeedRecorder
NewSpeedRecorder new a SpeedRecorder.
func (*SpeedRecorder) GetSpeed ¶
func (s *SpeedRecorder) GetSpeed(finished float64) float64
GetSpeed calculate status speed.
type StringIter ¶
StringIter is the iterator on a collection of strings.
type Stringer ¶
type Stringer interface { WriteToBuffer(*bytes.Buffer, bool) WriteToBufferInCsv(*bytes.Buffer, bool, *csvOption) }
Stringer is an interface which represents sql types that support writing to buffer in sql/csv type
type TableDataIR ¶
type TableDataIR interface { Start(*tcontext.Context, *sql.Conn) error Rows() SQLRowIter Close() error RawRows() *sql.Rows }
TableDataIR is table data intermediate representation. A table may be split into multiple TableDataIRs.
func SelectAllFromTable ¶
func SelectAllFromTable(conf *Config, meta TableMeta, partition, orderByClause string) TableDataIR
SelectAllFromTable dumps data serialized from a specified table
type TableMeta ¶
type TableMeta interface { DatabaseName() string TableName() string ColumnCount() uint ColumnTypes() []string ColumnNames() []string SelectedField() string SelectedLen() int SpecialComments() StringIter ShowCreateTable() string ShowCreateView() string AvgRowLength() uint64 HasImplicitRowID() bool }
TableMeta contains the meta information of a table.
type TableType ¶
type TableType int8
TableType represents the type of table
func ParseTableType ¶
ParseTableType parses table type string to TableType
type Task ¶
type Task interface { // Brief is the brief for a dumping task Brief() string }
Task is a file dump task for dumpling, it could either be dumping database/table/view/policy metadata, table data
type TaskDatabaseMeta ¶
TaskDatabaseMeta is a dumping database metadata task
func NewTaskDatabaseMeta ¶
func NewTaskDatabaseMeta(dbName, createSQL string) *TaskDatabaseMeta
NewTaskDatabaseMeta returns a new dumping database metadata task
func (*TaskDatabaseMeta) Brief ¶
func (t *TaskDatabaseMeta) Brief() string
Brief implements task.Brief
type TaskPolicyMeta ¶
TaskPolicyMeta is a dumping view metadata task
func NewTaskPolicyMeta ¶
func NewTaskPolicyMeta(policyName, createPolicySQL string) *TaskPolicyMeta
NewTaskPolicyMeta returns a new dumping placement policy metadata task
type TaskSequenceMeta ¶
type TaskSequenceMeta struct { Task DatabaseName string SequenceName string CreateSequenceSQL string }
TaskSequenceMeta is a dumping sequence metadata task
func NewTaskSequenceMeta ¶
func NewTaskSequenceMeta(dbName, tblName, createSequenceSQL string) *TaskSequenceMeta
NewTaskSequenceMeta returns a new dumping sequence metadata task
func (*TaskSequenceMeta) Brief ¶
func (t *TaskSequenceMeta) Brief() string
Brief implements task.Brief
type TaskTableData ¶
type TaskTableData struct { Task Meta TableMeta Data TableDataIR ChunkIndex int TotalChunks int }
TaskTableData is a dumping table data task
func NewTaskTableData ¶
func NewTaskTableData(meta TableMeta, data TableDataIR, currentChunk, totalChunks int) *TaskTableData
NewTaskTableData returns a new dumping table data task
type TaskTableMeta ¶
TaskTableMeta is a dumping table metadata task
func NewTaskTableMeta ¶
func NewTaskTableMeta(dbName, tblName, createSQL string) *TaskTableMeta
NewTaskTableMeta returns a new dumping table metadata task
type TaskViewMeta ¶
type TaskViewMeta struct { Task DatabaseName string ViewName string CreateTableSQL string CreateViewSQL string }
TaskViewMeta is a dumping view metadata task
func NewTaskViewMeta ¶
func NewTaskViewMeta(dbName, tblName, createTableSQL, createViewSQL string) *TaskViewMeta
NewTaskViewMeta returns a new dumping view metadata task
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is the abstraction that keep pulling data from database and write to files. Every writer owns a snapshot connection, and will try to get a task from task stream chan and work on it.
func NewWriter ¶
func NewWriter( tctx *tcontext.Context, id int64, config *Config, conn *sql.Conn, externalStore storage.ExternalStorage, metrics *metrics, ) *Writer
NewWriter returns a new Writer with given configurations
func (*Writer) WriteDatabaseMeta ¶
WriteDatabaseMeta writes database meta to a file
func (*Writer) WritePolicyMeta ¶
WritePolicyMeta writes database meta to a file
func (*Writer) WriteSequenceMeta ¶
WriteSequenceMeta writes sequence meta to a file
func (*Writer) WriteTableData ¶
func (w *Writer) WriteTableData(meta TableMeta, ir TableDataIR, currentChunk int) error
WriteTableData writes table data to a file with retry
func (*Writer) WriteTableMeta ¶
WriteTableMeta writes table meta to a file
func (*Writer) WriteViewMeta ¶
WriteViewMeta writes view meta to a file