sqlparser

package
v0.0.0-...-b97b37b Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StmtTypeUnknow  = "Unknow"
	StmtTypeSelect  = "Select"
	StmtTypeUpdate  = "Update"
	StmtTypeDelete  = "Delete"
	StmtTypeInsert  = "Insert"
	StmtTypeCreate  = "Create"
	StmtTypeAlter   = "Alter"
	StmtTypeExplain = "Explain"
)

Variables

This section is empty.

Functions

func CreateInsertSqlsByRows

func CreateInsertSqlsByRows(insertStmt *ast.InsertStmt, rows [][]interface{}, batchCount int64, endStr string) ([]string, error)

func CreateInsertStmtTemplate

func CreateInsertStmtTemplate(dbName, tableName string, columnNames []string) (*ast.InsertStmt, error)

func CreateInsertStmtsByRows

func CreateInsertStmtsByRows(insertStmt *ast.InsertStmt, rows [][]interface{}, batchCount int64) ([]*ast.InsertStmt, error)

func ExistsCreateTableStmt

func ExistsCreateTableStmt(sqlStr string) (bool, error)

func FindDBNamesByStmtNode

func FindDBNamesByStmtNode(stmtNode ast.StmtNode) []string

获取语句的数据库

func GetAllAlterTableNames

func GetAllAlterTableNames(sqlStrs []string) ([]string, error)

获取所有Alter table表名

func GetAllCreateTableNames

func GetAllCreateTableNames(sqlStrs []string) ([]string, error)

获取所有Create table表名

func GetDDLTableName

func GetDDLTableName(sqlStr string) (string, error)

获取DDL表名

func GetSQLStmtHearderComment

func GetSQLStmtHearderComment(stmt string) string

func GetSQLStmtHearderCommentEndPos

func GetSQLStmtHearderCommentEndPos(stmt string) int

func GetStmtType

func GetStmtType(stmtNode ast.StmtNode) string

func GetStmtType2

func GetStmtType2(sqlStr string) string

func IsAllDDL

func IsAllDDL(sqlStr string) (bool, []error, error)

func IsCreateTableStmt

func IsCreateTableStmt(sqlStr string) (bool, error)

func NewRow

func NewRow(fields []interface{}) []ast.ExprNode

func NewRows

func NewRows(dataz [][]interface{}) [][]ast.ExprNode

func NormalizeDigest

func NormalizeDigest(sqlStr string) (string, string)

func ParseOneStmt

func ParseOneStmt(query string) (ast.StmtNode, error)

func ReplaceDDLTableName

func ReplaceDDLTableName(sqlStr string, replaceTableName string) (string, error)

func ReplaceDDLTableNames

func ReplaceDDLTableNames(sqlStr string, replaceTableNames []string) ([]string, error)

func ReplaceDDLsTableName

func ReplaceDDLsTableName(sqlStrs []string, logicRealTableNameMap map[string]string) ([]string, error)

替换所有DDL表名

func ResetSelectLimitAndGet

func ResetSelectLimitAndGet(stmtNode ast.StmtNode, defaultLimit int64) ast.StmtNode

func RestoreSql

func RestoreSql(node ast.Node, endStr string) (string, error)

重写sql

func SqlToMulti

func SqlToMulti(sqlStr string) ([]string, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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