parser

package
v0.0.0-...-44a46bf Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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

func CheckIsDDL(sql string, p *parser.Parser) bool

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 Parse

func Parse(p *parser.Parser, sql, charset, collation string) (stmt []ast.StmtNode, err error)

Parse wraps parser.Parse(), makes `parser` suitable for dm.

func RenameDDLTable

func RenameDDLTable(stmt ast.StmtNode, targetTables []*filter.Table) (string, error)

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

func SplitDDL(stmt ast.StmtNode, schema string) (sqls []string, err error)

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.

Jump to

Keyboard shortcuts

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