Documentation ¶
Index ¶
- Variables
- func AlterTableSpecFormat(stmt *ast.AlterTableSpec) string
- func AlterTableStmtFormat(stmt *ast.AlterTableStmt) string
- func CheckWhereFuzzySearch(where ast.ExprNode) bool
- func ExprFormat(node ast.ExprNode) string
- func ExtractIndexFromCreateTableStmt(table *ast.CreateTableStmt) map[string][]string
- func Fingerprint(oneSql string, isCaseSensitive bool) (fingerprint string, err error)
- func GetAlterTableSpecByTp(specs []*ast.AlterTableSpec, ts ...ast.AlterTableType) []*ast.AlterTableSpec
- func GetLimitCount(limit *ast.Limit, _default int64) (int64, error)
- func GetNumberOfJoinTables(stmt *ast.Join) int
- func GetPrimaryKey(stmt *ast.CreateTableStmt) (map[string]struct{}, bool)
- func GetTableNameWithQuote(stmt *ast.TableName) string
- func GetTableSources(stmt *ast.Join) []*ast.TableSource
- func GetTables(stmt *ast.Join) []*ast.TableName
- func HasOneInOptions(Options []*ast.ColumnOption, opTp ...ast.ColumnOptionType) bool
- func HasPrimaryKey(stmt *ast.CreateTableStmt) bool
- func HasUniqIndex(stmt *ast.CreateTableStmt) bool
- func IndexOptionFormat(op *ast.IndexOption) string
- func IsAllInOptions(Options []*ast.ColumnOption, opTp ...ast.ColumnOptionType) bool
- func IsColumnImplicitConversionInWhereStmt(colTypeMap map[string]string, where ast.ExprNode) bool
- func IsFuncUsedOnColumnInWhereStmt(cols map[string]struct{}, where ast.ExprNode) bool
- func MergeAlterToTable(oldTable *ast.CreateTableStmt, alterTable *ast.AlterTableStmt) (*ast.CreateTableStmt, error)
- func MysqlDataTypeIsBlob(tp byte) bool
- func NewTableName(schema, table string) *ast.TableName
- func ParseCreateTableStmt(sql string) (*ast.CreateTableStmt, error)
- func ParseOneSql(sql string) (ast.StmtNode, error)
- func ParseSql(sql string) ([]ast.StmtNode, error)
- func RemoveArrayRepeat(input []string) (output []string)
- func ScanWhereStmt(fn func(expr ast.ExprNode) (skip bool), exprs ...ast.ExprNode)
- func TableExistCol(table *ast.CreateTableStmt, colName string) bool
- func WhereStmtExistNot(where ast.ExprNode) bool
- func WhereStmtExistScalarSubQueries(where ast.ExprNode) bool
- func WhereStmtHasOneColumn(where ast.ExprNode) bool
- func WhereStmtHasSubQuery(where ast.ExprNode) bool
- type CapitalizeProcessor
- type FingerprintVisitor
- type SelectStmtExtractor
- type TableChecker
- type TableNameExtractor
Constants ¶
This section is empty.
Variables ¶
var ColumnOptionMap = map[ast.ColumnOptionType]string{ ast.ColumnOptionNotNull: "NOT NULL", ast.ColumnOptionNull: "NULL", ast.ColumnOptionAutoIncrement: "AUTO_INCREMENT", ast.ColumnOptionPrimaryKey: "PRIMARY KEY", ast.ColumnOptionUniqKey: "UNIQUE KEY", }
Functions ¶
func AlterTableSpecFormat ¶
func AlterTableSpecFormat(stmt *ast.AlterTableSpec) string
func AlterTableStmtFormat ¶
func AlterTableStmtFormat(stmt *ast.AlterTableStmt) string
func CheckWhereFuzzySearch ¶
Check is exist a full fuzzy query or a left fuzzy query. E.g: %name% or %name
func ExprFormat ¶
func ExtractIndexFromCreateTableStmt ¶
func ExtractIndexFromCreateTableStmt(table *ast.CreateTableStmt) map[string][]string
ExtractIndexFromCreateTableStmt extract index from create table statement.
func Fingerprint ¶
func GetAlterTableSpecByTp ¶
func GetAlterTableSpecByTp(specs []*ast.AlterTableSpec, ts ...ast.AlterTableType) []*ast.AlterTableSpec
func GetNumberOfJoinTables ¶
func GetPrimaryKey ¶
func GetPrimaryKey(stmt *ast.CreateTableStmt) (map[string]struct{}, bool)
func GetTableNameWithQuote ¶
func GetTableSources ¶
func GetTableSources(stmt *ast.Join) []*ast.TableSource
func HasOneInOptions ¶
func HasOneInOptions(Options []*ast.ColumnOption, opTp ...ast.ColumnOptionType) bool
func HasPrimaryKey ¶
func HasPrimaryKey(stmt *ast.CreateTableStmt) bool
func HasUniqIndex ¶
func HasUniqIndex(stmt *ast.CreateTableStmt) bool
func IndexOptionFormat ¶
func IndexOptionFormat(op *ast.IndexOption) string
func IsAllInOptions ¶
func IsAllInOptions(Options []*ast.ColumnOption, opTp ...ast.ColumnOptionType) bool
func MergeAlterToTable ¶
func MergeAlterToTable(oldTable *ast.CreateTableStmt, alterTable *ast.AlterTableStmt) (*ast.CreateTableStmt, error)
func MysqlDataTypeIsBlob ¶
func NewTableName ¶
func ParseCreateTableStmt ¶
func ParseCreateTableStmt(sql string) (*ast.CreateTableStmt, error)
func RemoveArrayRepeat ¶
func ScanWhereStmt ¶
func TableExistCol ¶
func TableExistCol(table *ast.CreateTableStmt, colName string) bool
func WhereStmtExistNot ¶
func WhereStmtHasOneColumn ¶
func WhereStmtHasSubQuery ¶
Types ¶
type CapitalizeProcessor ¶
type CapitalizeProcessor struct {
// contains filtered or unexported fields
}
CapitalizeProcessor implements ast.Visitor interface.
CapitalizeProcessor capitalize identifiers as needed.
format.RestoreNameUppercase can not control name comparisons accurate. CASE: Database/Table/Table-alias names are case-insensitive when lower_case_table_names equals 1. Some identifiers, such as Tablespace names are case-sensitive which not affected by lower_case_table_names. ref: https://dev.mysql.com/doc/refman/5.7/en/identifier-case-sensitivity.html
type FingerprintVisitor ¶
type FingerprintVisitor struct{}
FingerprintVisitor implements ast.Visitor interface.
type SelectStmtExtractor ¶
type SelectStmtExtractor struct {
SelectStmts []*ast.SelectStmt
}
type TableChecker ¶
type TableChecker struct {
// contains filtered or unexported fields
}
func NewTableChecker ¶
func NewTableChecker() *TableChecker
func (*TableChecker) Add ¶
func (t *TableChecker) Add(schemaName, tableName string, table *ast.CreateTableStmt)
func (*TableChecker) CheckColumnByName ¶
func (t *TableChecker) CheckColumnByName(colNameStmt *ast.ColumnName) (bool, bool)
type TableNameExtractor ¶
TableNameExtractor implements ast.Visitor interface.