tidb

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ANTLRParseTiDB

func ANTLRParseTiDB(statement string) ([]*base.ParseResult, error)

func DealWithDelimiter

func DealWithDelimiter(statement string) (string, error)

DealWithDelimiter converts the delimiter statement to comment, also converts the following statement's delimiter to semicolon(`;`).

func Diagnose

func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]base.Diagnostic, error)

func ExtractDelimiter

func ExtractDelimiter(stmt string) (string, error)

ExtractDelimiter extracts the delimiter from the delimiter statement.

func ExtractMySQLTableList

func ExtractMySQLTableList(in ast.Node, asName bool) []*ast.TableName

ExtractMySQLTableList extracts all the TableNames from node. If asName is true, extract AsName prior to OrigName.

func GetQuerySpan

func GetQuerySpan(ctx context.Context, gCtx base.GetQuerySpanContext, statement, database, _ string, _ bool) (*base.QuerySpan, error)

func GetStatementTypes

func GetStatementTypes(asts []base.AST) ([]string, error)

func IsDelimiter

func IsDelimiter(stmt string) bool

IsDelimiter returns true if the statement is a delimiter statement.

func IsTiDBUnsupportDDLStmt

func IsTiDBUnsupportDDLStmt(stmt string) bool

IsTiDBUnsupportDDLStmt checks whether the `stmt` is unsupported DDL statement in TiDB, the following statements are unsupported: 1. `CREATE TRIGGER` 2. `CREATE EVENT` 3. `CREATE FUNCTION` 4. `CREATE PROCEDURE`.

func NormalizeTiDBIdentifier

func NormalizeTiDBIdentifier(identifier parser.IIdentifierContext) string

NormalizeTiDBIdentifier normalizes the given identifier.

func NormalizeTiDBTextOrIdentifier

func NormalizeTiDBTextOrIdentifier(ctx parser.ITextOrIdentifierContext) string

NormalizeTiDBTextOrIdentifier normalizes the given TextOrIdentifier.

func ParseTiDB

func ParseTiDB(sql string, charset string, collation string) ([]ast.StmtNode, error)

ParseTiDB parses the given SQL statement and returns the AST.

func ParseTiDBForSyntaxCheck

func ParseTiDBForSyntaxCheck(statement string) ([]base.AST, error)

ParseTiDBForSyntaxCheck parses TiDB SQL for syntax checking purposes. Returns []base.AST with *TiDBAST instances.

func SetLineForMySQLCreateTableStmt

func SetLineForMySQLCreateTableStmt(node *ast.CreateTableStmt) error

SetLineForMySQLCreateTableStmt sets the line for columns and table constraints in MySQL CREATE TABLE statments. This is a temporary function. Because we do not convert tidb AST to our AST. So we have to implement this. TODO(rebelice): remove it.

func SplitSQL

func SplitSQL(statement string) ([]base.SingleSQL, error)

SplitSQL splits the given SQL statement into multiple SQL statements.

func TransformDMLToSelect

func TransformDMLToSelect(ctx context.Context, tCtx base.TransformContext, statement string, sourceDatabase string, targetDatabase string, tablePrefix string) ([]base.BackupStatement, error)

func TypeString

func TypeString(tp byte) string

TypeString returns the string representation of the type for MySQL.

Types

type AST

type AST struct {
	// StartPosition is the 1-based position where this statement starts.
	StartPosition *storepb.Position
	Node          tidbast.StmtNode
}

AST is the AST implementation for TiDB parser. It implements the base.AST interface.

func GetTiDBAST

func GetTiDBAST(a base.AST) (*AST, bool)

GetTiDBAST extracts the TiDB AST from a base.AST. Returns the AST and true if it is a TiDB AST, nil and false otherwise.

func (*AST) ASTStartPosition

func (a *AST) ASTStartPosition() *storepb.Position

ASTStartPosition implements base.AST interface.

type TableReference

type TableReference struct {
	Database string
	Table    string
	Alias    string
}

Jump to

Keyboard shortcuts

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