Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect int
Dialect enumerates supported SQL dialects.
const ( DialectInvalid Dialect = iota DialectMySQL DialectPostgres DialectSingleStore = DialectMySQL )
type Flag ¶
type Flag uint32
Flag is a bitmask describing statement / script properties.
type Statement ¶
type Statement struct {
Flags Flag
Tokens sqltoken.Tokens // unstripped tokens for this statement
// contains filtered or unexported fields
}
Statement represents one SQL statement with its original, unstripped tokens and classification flags.
func (Statement) StripString ¶
StripString returns the lowercased stripped string
type Statements ¶
type Statements []Statement
Statements is a slice of Statement.
func ClassifyTokens ¶
func ClassifyTokens(d Dialect, majorVersion int, sqlString string) (Statements, error)
ClassifyTokens tokenizes and classifies a SQL script, returning per-statement flags and original tokens. Only error case is invalid dialect. strings.Join(ClassifyTokens().TokensList.Strings, ";") should return the original sqlString
func (Statements) CountNonEmpty ¶
func (s Statements) CountNonEmpty() int
CountNonEmpty returns the number of real statements, excluding empty/comment-only and SET-leading statements.
func (Statements) FirstReal ¶
func (s Statements) FirstReal() *Statement
FirstReal returns a pointer to the first real statement (non-empty, non-SET) or nil if none.
func (Statements) Regroup ¶
func (s Statements) Regroup() []Statements
Regroup returns groups of statements that are compatible to run together in a single migration. Algorithm (single pass): Postgres: statements with IsMustNonTx must be isolated; all others can group together. MySQL: each DDL (IsDDL) isolated; consecutive/any DML grouped together. Mixed order preserved by starting a new group when incompatibility detected.
func (Statements) Summarize ¶
func (s Statements) Summarize() Summary
Summarize builds a Summary from the classified statements.
func (Statements) TokensList ¶
func (s Statements) TokensList() sqltoken.TokensList