MCPcopy Create free account
hub / github.com/bytebase/bytebase / GetStatementTypes

Function GetStatementTypes

backend/plugin/parser/tidb/statement_type.go:11–27  ·  view source on GitHub ↗
(asts []base.AST)

Source from the content-addressed store, hash-verified

9)
10
11func GetStatementTypes(asts []base.AST) ([]storepb.StatementType, error) {
12 sqlTypeSet := make(map[storepb.StatementType]bool)
13 for _, ast := range asts {
14 tidbAST, ok := GetTiDBAST(ast)
15 if !ok {
16 return nil, errors.New("expected TiDB AST")
17 }
18 node := tidbAST.Node
19 t := getStatementType(node)
20 sqlTypeSet[t] = true
21 }
22 var sqlTypes []storepb.StatementType
23 for sqlType := range sqlTypeSet {
24 sqlTypes = append(sqlTypes, sqlType)
25 }
26 return sqlTypes, nil
27}
28
29// getStatementType returns the type of statement.
30func getStatementType(stmt tidbast.StmtNode) storepb.StatementType {

Callers 1

TestGetStatementTypeFunction · 0.70

Calls 2

GetTiDBASTFunction · 0.85
getStatementTypeFunction · 0.70

Tested by 1

TestGetStatementTypeFunction · 0.56