Documentation
¶
Overview ¶
Package transformer wires the parser and rules together: the Engine applies rules to parsed statements, and DirProcessor runs the pipeline over directory trees in parallel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TransformString ¶ added in v1.3.0
TransformString runs the whole pipeline on a MariaDB script: preprocess and parse, apply the rules, write TiDB SQL, and check the output still has the input's tables, columns, keys and statements. Migration warnings go to report (may be nil). A nil cfg means the default configuration.
func VerifyOutput ¶ added in v1.3.0
VerifyOutput re-parses output with the TiDB parser and checks it still has the shape recorded before the transformation, so a bug anywhere in the pipeline cannot silently drop a table, column, key, row or statement.
Types ¶
type DirProcessor ¶
type DirProcessor struct {
// contains filtered or unexported fields
}
DirProcessor transforms all SQL files in a directory tree.
func NewDirProcessor ¶
func NewDirProcessor(cfg *config.Config) *DirProcessor
NewDirProcessor creates a directory processor. A nil cfg means the default configuration.
func (*DirProcessor) ProcessDirectory ¶
func (p *DirProcessor) ProcessDirectory(ctx context.Context, inputDir, outputDir string, workers int) error
ProcessDirectory mirrors inputDir into outputDir: schema .sql files are transformed, Dumpling data chunks and all other files (metadata, CSV, compressed chunks) are copied byte for byte, so the output directory is a complete source for TiDB Lightning. Workers controls the maximum number of files processed in parallel.
func (*DirProcessor) Warnings ¶ added in v1.3.0
func (p *DirProcessor) Warnings() []string
Warnings returns the migration warnings of the last run, prefixed with the file they came from.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine handles the transformation of SQL statements
func NewEngineWithReporter ¶ added in v1.3.0
NewEngineWithReporter creates an engine whose rules record migration warnings in r.
type Shape ¶ added in v1.3.0
type Shape []string
Shape is what no transformation may change, statement by statement and in order: tables with their columns, keys (including column-level ones, key order and DESC, foreign key targets and actions) and partitioning; views; INSERTs with their target, columns and row/value counts; ALTER TABLE specs; USE. Rules legitimately change types, defaults, options, key prefix lengths, clustering and CHECK constraints (MariaDB's JSON_VALID checks are dropped on purpose), so those are not part of it.