parser

package
v0.3.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ColumnColumnString        = "COLUMN"
	ColumnCharacterSetString  = "CHARACTER SET"
	ColumnCollateString       = "COLLATE"
	ColumnNotNullString       = "NOT NULL"
	ColumnAutoIncrementString = "AUTO_INCREMENT"
	ColumnDefaultString       = "DEFAULT"
	ColumnOnUpdateString      = "ON UPDATE"
	ColumnCommentString       = "COMMENT"
	ColumnFirstString         = "FIRST"
	ColumnAfterString         = "AFTER"

	ColumnDiffTypeUnknown ColumnDiffType = 0
	ColumnDiffTypeAdd     ColumnDiffType = 1
	ColumnDiffTypeChange  ColumnDiffType = 2
	ColumnDiffTypeDrop    ColumnDiffType = 3
)
View Source
const (
	ExpressionTypeUnknown ExpressionType = 0
	ExpressionTypeNull    ExpressionType = 1
	ExpressionTypeString  ExpressionType = 2
	ExpressionTypeFunc    ExpressionType = 3

	ExpressionTypeUnknownString = "UNKNOWN"
	ExpressionTypeNullString    = "NULL"
	ExpressionTypeStringString  = "STRING"
	ExpressionTypeFuncString    = "FUNC"
)
View Source
const (
	IndexPrimaryKeyName   = "PRIMARY"
	IndexDescendingString = "DESC"
	IndexIndexString      = "INDEX"
	IndexKeyString        = "KEY"
	IndexUniqueString     = "UNIQUE"
	IndexVisibleString    = "INVISIBLE"

	IndexDiffTypeUnknown IndexDiffType = 0
	IndexDiffTypeAdd     IndexDiffType = 1
	IndexDiffTypeDrop    IndexDiffType = 2
)
View Source
const (
	UnknownKeyWord = "UNKNOWN OPERATION"
	CreateKeyWord  = "CREATE"
	AlterKeyWord   = "ALTER"
	DropKeyWord    = "DROP"
	AddKeyword     = "ADD"
	ModifyKeyWord  = "MODIFY"
	ChangeKeyWord  = "CHANGE"
)
View Source
const (
	TableTableString     = "TABLE"
	TableRenameString    = "RENAME TO"
	TableEngineString    = "ENGINE"
	TableConvertString   = "CONVERT TO"
	TableCharsetString   = "CHARACTER SET"
	TableCollateString   = "COLLATE"
	TableRowFormatString = "ROW_FORMAT"
	TableCommentString   = "COMMENT"
	TableDropPrefix      = "--//## DANGER!: "

	TableDefaultRowFormat = "DEFAULT"

	TableDiffTypeUnknown TableDiffType = 0
	TableDiffTypeCreate  TableDiffType = 1
	TableDiffTypeAlter   TableDiffType = 2
	TableDiffTypeDrop    TableDiffType = 3
)
View Source
const (
	CreateTableStmtString = "*ast.CreateTableStmt"
	AlterTableStmtString  = "*ast.AlterTableStmt"
	DropTableStmtString   = "*ast.DropTableStmt"
	SelectStmtString      = "*ast.SelectStmt"
	UnionStmtString       = "*ast.UnionStmt"
	InsertStmtString      = "*ast.InsertStmt"
	ReplaceStmtString     = "*ast.ReplaceStmt"
	UpdateStmtString      = "*ast.UpdateStmt"
	DeleteStmtString      = "*ast.DeleteStmt"
	GrantStmtString       = "*ast.GrantStmt"

	FuncCallExprString      = "*ast.FuncCallExpr"
	AggregateFuncExprString = "*ast.AggregateFuncExpr"
	WindowFuncExprString    = "*ast.WindowFuncExpr"

	CurrentTimeStampFuncName = "current_timestamp"
)

Variables

Functions

func GetFullFuncName added in v0.3.21

func GetFullFuncName(funcName string, args ...string) string

Types

type ColumnDefinition added in v0.3.21

type ColumnDefinition struct {
	TableSchema      string      `json:"tableSchema"`
	TableName        string      `json:"tableName"`
	ColumnName       string      `json:"columnName"`
	DataType         string      `json:"dataType"`
	ColumnType       string      `json:"columnType"`
	DefaultValue     *Expression `json:"defaultValue"`
	OnUpdateValue    *Expression `json:"onUpdateValue"`
	CharacterSetName string      `json:"characterSetName"`
	CollationName    string      `json:"collationName"`
	IsAutoIncrement  bool        `json:"isAutoIncrement"`
	NotNull          bool        `json:"notNull"`
	OrdinalPosition  int         `json:"ordinalPosition"`
	ColumnComment    string      `json:"columnComment"`
	After            string      `json:"after"`
	IsFirst          bool        `json:"isFirst"`

	Errors *multierror.Error `json:"errors,omitempty"`
}

func NewColumnDefinition added in v0.3.21

func NewColumnDefinition(tableSchema, tableName, columnName string) *ColumnDefinition

NewColumnDefinition returns a new *ColumnDefinition

func NewEmptyColumnDefinition added in v0.3.21

func NewEmptyColumnDefinition() *ColumnDefinition

NewEmptyColumnDefinition returns a new empty *ColumnDefinition

func (*ColumnDefinition) AddError added in v0.3.21

func (cd *ColumnDefinition) AddError(err error)

AddError adds error to ColumnDefinition

func (*ColumnDefinition) Clone added in v0.3.21

func (cd *ColumnDefinition) Clone() *ColumnDefinition

Clone returns a new *ColumnDefinition

func (*ColumnDefinition) Diff added in v0.3.21

func (cd *ColumnDefinition) Diff(source *ColumnDefinition) *ColumnDiff

Diff returns the difference between two column definitions

func (*ColumnDefinition) Equal added in v0.3.21

func (cd *ColumnDefinition) Equal(other *ColumnDefinition) bool

Equal checks whether two ColumnDefinition objects are equal

func (*ColumnDefinition) Error added in v0.3.21

func (cd *ColumnDefinition) Error() error

Error returns the error of ColumnDefinition

func (*ColumnDefinition) String added in v0.3.21

func (cd *ColumnDefinition) String() string

String returns the string of ColumnDefinition

type ColumnDiff added in v0.3.21

type ColumnDiff struct {
	DiffType ColumnDiffType    `json:"diffType"`
	Source   *ColumnDefinition `json:"source"`
	Target   *ColumnDefinition `json:"target"`
}

func NewColumnDiff added in v0.3.21

func NewColumnDiff(diffType ColumnDiffType, source, target *ColumnDefinition) *ColumnDiff

func NewEmptyColumnDiff added in v0.3.21

func NewEmptyColumnDiff() *ColumnDiff

func (*ColumnDiff) GetMigrationSQL added in v0.3.21

func (cd *ColumnDiff) GetMigrationSQL() string

GetMigrationSQL gets the sql of column migration

func (*ColumnDiff) MarshalJSON added in v0.3.21

func (cd *ColumnDiff) MarshalJSON() ([]byte, error)

MarshalJSON returns the json of ColumnDiff

type ColumnDiffType added in v0.3.21

type ColumnDiffType int

func (*ColumnDiffType) MarshalJSON added in v0.3.21

func (cdt *ColumnDiffType) MarshalJSON() ([]byte, error)

func (*ColumnDiffType) String added in v0.3.21

func (cdt *ColumnDiffType) String() string

func (*ColumnDiffType) UnmarshalJSON added in v0.3.21

func (cdt *ColumnDiffType) UnmarshalJSON(b []byte) error

type Expression added in v0.3.21

type Expression struct {
	ExpressionType  ExpressionType
	ExpressionValue string
}

func NewExpression added in v0.3.21

func NewExpression(et ExpressionType, ev string) *Expression

func (*Expression) Equal added in v0.3.21

func (e *Expression) Equal(other *Expression) bool

func (*Expression) MarshalJSON added in v0.3.21

func (e *Expression) MarshalJSON() ([]byte, error)

func (*Expression) String added in v0.3.21

func (e *Expression) String() string

type ExpressionType added in v0.3.21

type ExpressionType int

func (*ExpressionType) MarshalJSON added in v0.3.21

func (et *ExpressionType) MarshalJSON() ([]byte, error)

func (*ExpressionType) String added in v0.3.21

func (et *ExpressionType) String() string

func (*ExpressionType) UnmarshalJSON added in v0.3.21

func (et *ExpressionType) UnmarshalJSON(b []byte) error

type IndexDefinition added in v0.3.21

type IndexDefinition struct {
	TableSchema string `json:"tableSchema"`
	TableName   string `json:"tableName"`
	IndexName   string `json:"indexName"`

	IsPrimary bool `json:"isPrimary"`
	IsUnique  bool `json:"isUnique"`
	IsVisible bool `json:"isVisible"`

	Columns []*IndexSpec `json:"columns"`

	Errors *multierror.Error `json:"errors,omitempty"`
}

Caution: for now, index definition does not include information below: - expressions on the indexed columns will be ignored - all indexes are assumed to be btree indexes

func NewEmptyIndexDefinition added in v0.3.21

func NewEmptyIndexDefinition() *IndexDefinition

NewEmptyIndexDefinition returns a new empty *IndexDefinition

func NewIndexDefinition added in v0.3.21

func NewIndexDefinition(tableSchema, tableName, indexName string) *IndexDefinition

NewIndexDefinition returns a new *IndexDefinition

func (*IndexDefinition) AddError added in v0.3.21

func (id *IndexDefinition) AddError(err error)

AddError adds error to IndexDefinition

func (*IndexDefinition) AddIndexSpec added in v0.3.21

func (id *IndexDefinition) AddIndexSpec(is *IndexSpec)

AddIndexSpec adds an index spec to the index definition

func (*IndexDefinition) Clone added in v0.3.21

func (id *IndexDefinition) Clone() *IndexDefinition

Clone returns a new *IndexDefinition

func (*IndexDefinition) Diff added in v0.3.21

func (id *IndexDefinition) Diff(source *IndexDefinition) []*IndexDiff

Diff returns the difference between two index definitions

func (*IndexDefinition) Equal added in v0.3.21

func (id *IndexDefinition) Equal(other *IndexDefinition) bool

Equal checks whether two IndexDefinition objects are equal

func (*IndexDefinition) Error added in v0.3.21

func (id *IndexDefinition) Error() error

Error returns the error of IndexDefinition

func (*IndexDefinition) HandleOption added in v0.3.21

func (id *IndexDefinition) HandleOption(option *ast.IndexOption)

HandleOption handles the option of the index

func (*IndexDefinition) String added in v0.3.21

func (id *IndexDefinition) String() string

String returns the string of IndexDefinition

type IndexDiff added in v0.3.21

type IndexDiff struct {
	DiffType IndexDiffType    `json:"diffType"`
	Source   *IndexDefinition `json:"source"`
	Target   *IndexDefinition `json:"target"`
}

func NewIndexDiff added in v0.3.21

func NewIndexDiff(diffType IndexDiffType, source, target *IndexDefinition) *IndexDiff

func (*IndexDiff) GetMigrationSQL added in v0.3.21

func (id *IndexDiff) GetMigrationSQL() string

GetMigrationSQL returns the migration sql of IndexDiff

func (*IndexDiff) MarshalJSON added in v0.3.21

func (id *IndexDiff) MarshalJSON() ([]byte, error)

MarshalJSON returns the json format of IndexDiff

type IndexDiffType added in v0.3.21

type IndexDiffType int

func (*IndexDiffType) MarshalJSON added in v0.3.21

func (idt *IndexDiffType) MarshalJSON() ([]byte, error)

func (*IndexDiffType) String added in v0.3.21

func (idt *IndexDiffType) String() string

func (*IndexDiffType) UnmarshalJSON added in v0.3.21

func (idt *IndexDiffType) UnmarshalJSON(b []byte) error

type IndexSpec added in v0.3.21

type IndexSpec struct {
	Column     *ColumnDefinition `json:"column"`
	Descending bool              `json:"descending"`
	Length     int               `json:"length"`
	Expr       *Expression       `json:"expr"`
}

func NewIndexSpec added in v0.3.21

func NewIndexSpec(cd *ColumnDefinition, descending bool, length int, expr *Expression) *IndexSpec

NewIndexSpec returns a new *IndexSpec

func (*IndexSpec) Clone added in v0.3.21

func (is *IndexSpec) Clone() *IndexSpec

Clone() returns a new *IndexSpec

func (*IndexSpec) Equal added in v0.3.21

func (is *IndexSpec) Equal(other *IndexSpec) bool

Equal checks whether two IndexSpec objects are equal

func (*IndexSpec) String added in v0.3.21

func (is *IndexSpec) String() string

String returns the string of IndexSpec

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(visitor *Visitor) *Parser

NewParser returns a new *Parser

func NewParserWithDefault added in v0.3.4

func NewParserWithDefault() *Parser

NewParserWithDefault returns a new *Parser with default visitor

func (*Parser) GetFingerprint added in v0.3.5

func (p *Parser) GetFingerprint(sql string) string

GetFingerprint returns fingerprint of the given sql

func (*Parser) GetSQL added in v0.3.21

func (p *Parser) GetSQL() string

GetSQL returns the sql of the parser

func (*Parser) GetSQLID added in v0.3.5

func (p *Parser) GetSQLID(sql string) string

GetSQLID returns the sql id of the given sql

func (*Parser) GetStatementNodes added in v0.3.8

func (p *Parser) GetStatementNodes(sql string) ([]ast.StmtNode, error)

GetStatementNodes gets the statement nodes of the given sql

func (*Parser) GetTiDBParser added in v0.3.6

func (p *Parser) GetTiDBParser() *parser.Parser

GetTiDBParser returns the TiDB parser

func (*Parser) GetVisitor added in v0.3.6

func (p *Parser) GetVisitor() *Visitor

GetVisitor returns the visitor

func (*Parser) MergeDDLStatements added in v0.3.8

func (p *Parser) MergeDDLStatements(sqls ...string) ([]string, error)

MergeDDLStatements merges ddl statements by table names. note that only alter table statement and create index statement will be merged, inputting other sql statements will return error, each argument in the input sqls could contain multiple sql statements

func (*Parser) Parse

func (p *Parser) Parse(sql string) (*Result, error)

Parse parses sql and returns the result, not that only some kinds of statements will be parsed, see the constants defined at the top of visitor.go file

func (*Parser) ParseTableDefinition added in v0.3.21

func (p *Parser) ParseTableDefinition(sql string) (*TableFullDefinition, error)

ParseTableDefinition gets the table definition of the given sql

func (*Parser) RemoveSQLComments added in v0.3.10

func (p *Parser) RemoveSQLComments(sql string) string

RemoveSQLComments removes comments of the sql

func (*Parser) SetParseTableDefinition added in v0.3.21

func (p *Parser) SetParseTableDefinition(parseTableDefinition bool)

SetParseTableDefinition sets the parse table definition flag of the visitor

func (*Parser) Split

func (p *Parser) Split(multiSQL string) ([]string, error)

Split splits multiple sql statements into a slice

type Result

type Result struct {
	SQLType        string                       `json:"sql_type"`
	TableDBListMap map[string][]string          `json:"table_db_list_map"`
	DBNames        []string                     `json:"db_names"`
	TableNames     []string                     `json:"table_names"`
	TableComments  map[string]string            `json:"table_comments"`
	ColumnNames    []string                     `json:"column_names"`
	ColumnTypes    map[string]string            `json:"column_types"`
	ColumnComments map[string]string            `json:"column_comments"`
	User           string                       `json:"user"`
	Privileges     map[mysql.PrivilegeType]bool `json:"privileges"`
}

func NewEmptyResult

func NewEmptyResult() *Result

NewEmptyResult returns an empty *Result

func NewResult

func NewResult(sqlType string, TableDBListMap map[string][]string, dbNames []string, tableNames []string,
	tableComments map[string]string, columnNames []string, columnTypes map[string]string,
	columnComments map[string]string, user string, privileges map[mysql.PrivilegeType]bool) *Result

NewResult returns a new *Result

func (*Result) AddColumn added in v0.3.4

func (r *Result) AddColumn(columnName string)

AddColumn adds column name to the result

func (*Result) AddDBName added in v0.3.4

func (r *Result) AddDBName(dbName string)

AddDBName adds db name to the result

func (*Result) AddPrivilege added in v0.3.21

func (r *Result) AddPrivilege(privilege mysql.PrivilegeType, withGrant bool)

AddPrivilege adds privilege to the result

func (*Result) AddTableDBListMap added in v0.3.11

func (r *Result) AddTableDBListMap(tableName string, dbName string)

AddTableDBListMap adds db name to the result

func (*Result) AddTableName added in v0.3.4

func (r *Result) AddTableName(tableName string)

AddTableName adds table name to the result

func (*Result) GetColumnComments added in v0.3.4

func (r *Result) GetColumnComments() map[string]string

GetColumnComments returns the column comments

func (*Result) GetColumnNames added in v0.3.4

func (r *Result) GetColumnNames() []string

GetColumnNames returns the column names

func (*Result) GetColumnTypes added in v0.3.5

func (r *Result) GetColumnTypes() map[string]string

GetColumnTypes returns the column types

func (*Result) GetDBNames added in v0.3.4

func (r *Result) GetDBNames() []string

GetDBNames returns the db names

func (*Result) GetSQLType added in v0.3.4

func (r *Result) GetSQLType() string

GetSQLType returns the sql type

func (*Result) GetTableComments added in v0.3.4

func (r *Result) GetTableComments() map[string]string

GetTableComments returns the table comments

func (*Result) GetTableDBListMap added in v0.3.11

func (r *Result) GetTableDBListMap() map[string][]string

GetTableDBListMap returns table db list map

func (*Result) GetTableNames added in v0.3.4

func (r *Result) GetTableNames() []string

GetTableNames returns the table names

func (*Result) SetColumnComment added in v0.3.4

func (r *Result) SetColumnComment(columnName string, columnComment string)

SetColumnComment sets column comment of corresponding column

func (*Result) SetColumnType added in v0.3.5

func (r *Result) SetColumnType(columnName string, columnType string)

SetColumnType sets column type of corresponding column

func (*Result) SetSQLType added in v0.3.4

func (r *Result) SetSQLType(sqlType string)

SetSQLType sets the sql type

func (*Result) SetTableComment added in v0.3.4

func (r *Result) SetTableComment(tableName string, tableComment string)

SetTableComment sets table comment of corresponding table

func (*Result) SetUser added in v0.3.21

func (r *Result) SetUser(user string)

SetUser sets user of the result

type TableDefinition added in v0.3.21

type TableDefinition struct {
	CreateTableSQL string `json:"-"`
	TableSchema    string `json:"tableSchema,omitempty"`
	TableName      string `json:"tableName,omitempty"`
	TableEngine    string `json:"tableEngine,omitempty"`
	Charset        string `json:"charset,omitempty"`
	Collation      string `json:"collation,omitempty"`
	RowFormat      string `json:"rowFormat,omitempty"`
	TableComment   string `json:"tableComment,omitempty"`
}

func NewEmptyTableDefinition added in v0.3.21

func NewEmptyTableDefinition() *TableDefinition

NewEmptyTableDefinition returns a new empty *TableDefinition

func NewTableDefinition added in v0.3.21

func NewTableDefinition(sql, tableName, tableEngine, charset, collation, rowFormat, tableComment string) *TableDefinition

NewTableDefinition returns a new *TableDefinition

func (*TableDefinition) Clone added in v0.3.21

func (td *TableDefinition) Clone() *TableDefinition

Clone returns a new *TableDefinition

func (*TableDefinition) Diff added in v0.3.21

func (td *TableDefinition) Diff(source *TableDefinition) *TableDiff

Diff returns the difference between two table definitions

func (*TableDefinition) Equal added in v0.3.21

func (td *TableDefinition) Equal(other *TableDefinition) bool

Equal checks whether two TableDefinition objects are equal

func (*TableDefinition) GetFullTableName added in v0.3.21

func (td *TableDefinition) GetFullTableName() string

GetFullTableName gets the full table name

func (*TableDefinition) GetTableName added in v0.3.21

func (td *TableDefinition) GetTableName() string

GetTableName gets the table name

func (*TableDefinition) String added in v0.3.21

func (td *TableDefinition) String() string

String returns the string of TableDefinition

type TableDefinitionDiff added in v0.3.21

type TableDefinitionDiff struct {
	Source     string        `json:"source"`
	Target     string        `json:"target"`
	TableDiff  *TableDiff    `json:"tableDiff"`
	ColumnDiff []*ColumnDiff `json:"columnDiff"`
	IndexDiff  []*IndexDiff  `json:"indexDiff"`
}

func NewEmptyTableDefinitionDiff added in v0.3.21

func NewEmptyTableDefinitionDiff() *TableDefinitionDiff

NewEmptyTableDefinitionDiff returns a new empty *TableDefinitionDiff

func NewTableDefinitionDiff added in v0.3.21

func NewTableDefinitionDiff(source, target string, tableDiff *TableDiff,
	columnDiff []*ColumnDiff, indexDiff []*IndexDiff) *TableDefinitionDiff

NewTableDefinitionDiff returns a new *TableDefinitionDiff

func (*TableDefinitionDiff) GetTableMigrationSQL added in v0.3.21

func (tdd *TableDefinitionDiff) GetTableMigrationSQL() string

GetTableMigrationSQL returns the migration sql of TableDefinitionDiff

type TableDiff added in v0.3.21

type TableDiff struct {
	DiffType TableDiffType    `json:"diffType"`
	Source   *TableDefinition `json:"source,omitempty"`
	Target   *TableDefinition `json:"target,omitempty"`
}

func NewEmptyTableDiff added in v0.3.21

func NewEmptyTableDiff() *TableDiff

NewEmptyTableDiff returns a new empty *TableDiff

func NewTableDiff added in v0.3.21

func NewTableDiff(diffType TableDiffType, source, target *TableDefinition) *TableDiff

NewTableDiff returns a new *TableDiff

func (*TableDiff) GetTableMigrationSQL added in v0.3.21

func (td *TableDiff) GetTableMigrationSQL() string

GetTableMigrationSQL returns the migration sql of TableDiff

type TableDiffType added in v0.3.21

type TableDiffType int

func (*TableDiffType) MarshalJSON added in v0.3.21

func (tdt *TableDiffType) MarshalJSON() ([]byte, error)

func (*TableDiffType) String added in v0.3.21

func (tdt *TableDiffType) String() string

func (*TableDiffType) UnmarshalJSON added in v0.3.21

func (tdt *TableDiffType) UnmarshalJSON(b []byte) error

type TableFullDefinition added in v0.3.21

type TableFullDefinition struct {
	CreateTableSQL string                       `json:"createTableSQL"`
	Table          *TableDefinition             `json:"table"`
	Columns        []*ColumnDefinition          `json:"columns"`
	ColumnMap      map[string]*ColumnDefinition `json:"-"`
	Indexes        map[string]*IndexDefinition  `json:"indexes"`
}

Caution: for now, table definition does not include information below: - only base table, no view - no partition info - no foreign key info - some table options are not included, for example: auto_increment, compression, encryption, etc...

- also see index.go for more limitations

func NewEmptyTableFullDefinition added in v0.3.21

func NewEmptyTableFullDefinition() *TableFullDefinition

NewEmptyTableFullDefinition returns a new empty *TableFullDefinition

func (*TableFullDefinition) AddColumn added in v0.3.21

func (td *TableFullDefinition) AddColumn(cd *ColumnDefinition)

AddColumn adds a column to the table definition

func (*TableFullDefinition) AddIndex added in v0.3.21

func (td *TableFullDefinition) AddIndex(id *IndexDefinition)

AddIndex adds an index to the table definition

func (*TableFullDefinition) Diff added in v0.3.21

Diff returns the difference between two table definitions

func (*TableFullDefinition) Equal added in v0.3.21

func (td *TableFullDefinition) Equal(other *TableFullDefinition) bool

Equal checks whether two TableFullDefinition objects are equal

func (*TableFullDefinition) Error added in v0.3.21

func (td *TableFullDefinition) Error() error

Error returns error

func (*TableFullDefinition) GetColumnDefinition added in v0.3.21

func (td *TableFullDefinition) GetColumnDefinition(columnName string) *ColumnDefinition

GetColumnDefinition gets the column definition by column name

func (*TableFullDefinition) MaintainOrdinalPosition added in v0.3.21

func (td *TableFullDefinition) MaintainOrdinalPosition(diffType ColumnDiffType, ordinalPosition int)

MaintainOrdinalPosition maintains the ordinal position of the columns

type Visitor

type Visitor struct {
	// contains filtered or unexported fields
}

func NewVisitor

func NewVisitor(sqlList, funcList []string) *Visitor

NewVisitor returns a new *Visitor

func NewVisitorWithDefault added in v0.3.4

func NewVisitorWithDefault() *Visitor

NewVisitorWithDefault returns a new *Visitor with default sql list and function list

func (*Visitor) Enter

func (v *Visitor) Enter(in ast.Node) (out ast.Node, skipChildren bool)

Enter enters into the given node, it will traverse each child node to find useful information such as table name, column name... note that it only traverses some kinds of node types, see the constants at the top of this file

func (*Visitor) GetFuncList added in v0.3.4

func (v *Visitor) GetFuncList() []string

GetFuncList returns the function list

func (*Visitor) GetResult added in v0.3.4

func (v *Visitor) GetResult() *Result

GetResult returns the result

func (*Visitor) GetSQLList added in v0.3.4

func (v *Visitor) GetSQLList() []string

GetSQLList returns the sql list

func (*Visitor) Leave

func (v *Visitor) Leave(in ast.Node) (out ast.Node, ok bool)

Leave leaves the given node, traversal is over

func (*Visitor) SetParseTableDefinition added in v0.3.21

func (v *Visitor) SetParseTableDefinition(sql string, parseTableDefinition bool)

SetParseTableDefinition sets the flag to parse table definition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL