MCPcopy Index your code
hub / github.com/bytebase/bytebase / parsePLSQLStatements

Function parsePLSQLStatements

backend/plugin/parser/plsql/plsql.go:22–60  ·  view source on GitHub ↗

parsePLSQLStatements is the ParseStatementsFunc for Oracle (PL/SQL). Returns []ParsedStatement with both text and AST populated.

(statement string)

Source from the content-addressed store, hash-verified

20// parsePLSQLStatements is the ParseStatementsFunc for Oracle (PL/SQL).
21// Returns []ParsedStatement with both text and AST populated.
22func parsePLSQLStatements(statement string) ([]base.ParsedStatement, error) {
23 stmts, err := SplitSQL(statement)
24 if err != nil {
25 return nil, err
26 }
27
28 var result []base.ParsedStatement
29 for _, stmt := range stmts {
30 if stmt.Empty {
31 result = append(result, base.ParsedStatement{Statement: stmt})
32 continue
33 }
34
35 list, err := ParsePLSQLOmni(stmt.Text)
36 if err != nil {
37 return nil, convertOmniError(err, stmt)
38 }
39 if list == nil || len(list.Items) == 0 {
40 result = append(result, base.ParsedStatement{Statement: stmt})
41 continue
42 }
43 for _, node := range list.Items {
44 raw, ok := node.(*ast.RawStmt)
45 if !ok {
46 continue
47 }
48 result = append(result, base.ParsedStatement{
49 Statement: stmt,
50 AST: &OmniAST{
51 Node: raw.Stmt,
52 Text: stmt.Text,
53 StartPosition: stmt.Start,
54 },
55 })
56 }
57 }
58
59 return result, nil
60}
61
62type Version struct {
63 First int

Callers

nothing calls this directly

Calls 3

ParsePLSQLOmniFunction · 0.85
SplitSQLFunction · 0.70
convertOmniErrorFunction · 0.70

Tested by

no test coverage detected