Documentation ¶
Index ¶
- Constants
- func CheckIsDDL(sql string, p *parser.Parser) bool
- func FetchDDLTables(schema string, stmt ast.StmtNode, flavor conn.LowerCaseTableNamesFlavor) ([]*filter.Table, error)
- func Parse(p *parser.Parser, sql, charset, collation string) (stmt []ast.StmtNode, err error)
- func RenameDDLTable(stmt ast.StmtNode, targetTables []*filter.Table) (string, error)
- func SplitDDL(stmt ast.StmtNode, schema string) (sqls []string, err error)
Constants ¶
const ( // SingleRenameTableNameNum stands for number of TableNames in a single table renaming. it's 2 after // https://github.com/pingcap/parser/pull/1021 SingleRenameTableNameNum = 2 )
Variables ¶
This section is empty.
Functions ¶
func CheckIsDDL ¶
CheckIsDDL checks input SQL whether is a valid DDL statement.
func FetchDDLTables ¶
func FetchDDLTables(schema string, stmt ast.StmtNode, flavor conn.LowerCaseTableNamesFlavor) ([]*filter.Table, error)
FetchDDLTables returns tables in ddl the result contains many tables. Because we use visitor pattern, first tableName is always upper-most table in ast specifically, for `create table like` DDL, result contains [sourceTable, sourceRefTable] for rename table ddl, result contains [old1, new1, old2, new2, old3, new3, ...] because of TiDB parser for other DDL, order of tableName is the node visit order.
func RenameDDLTable ¶
RenameDDLTable renames tables in ddl by given `targetTables` argument `targetTables` is same with return value of FetchDDLTables returned DDL is formatted like StringSingleQuotes, KeyWordUppercase and NameBackQuotes.
func SplitDDL ¶
SplitDDL splits multiple operations in one DDL statement into multiple DDL statements returned DDL is formatted like StringSingleQuotes, KeyWordUppercase and NameBackQuotes if fail to restore, it would not restore the value of `stmt` (it changes it's values if `stmt` is one of DropTableStmt, RenameTableStmt, AlterTableStmt).
Types ¶
This section is empty.