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

Function findFirstOracleDML

backend/plugin/parser/plsql/restore.go:46–77  ·  view source on GitHub ↗
(statement string)

Source from the content-addressed store, hash-verified

44}
45
46func findFirstOracleDML(statement string) (oracleast.StmtNode, error) {
47 node, err := findFirstOracleDMLOnce(statement)
48 if err == nil {
49 return node, nil
50 }
51 if !strings.Contains(statement, "\n") {
52 return nil, errors.Wrap(err, "failed to parse statement")
53 }
54
55 lines := strings.Split(statement, "\n")
56 for start := range lines {
57 var candidate strings.Builder
58 for end := start; end < len(lines); end++ {
59 line := strings.TrimSpace(lines[end])
60 if line == "" && candidate.Len() == 0 {
61 continue
62 }
63 if candidate.Len() > 0 {
64 candidate.WriteByte('\n')
65 }
66 candidate.WriteString(lines[end])
67 node, candidateErr := findFirstOracleDMLOnce(candidate.String())
68 if candidateErr != nil {
69 continue
70 }
71 if node != nil {
72 return node, nil
73 }
74 }
75 }
76 return nil, errors.Wrap(err, "failed to parse statement")
77}
78
79func findFirstOracleDMLOnce(statement string) (oracleast.StmtNode, error) {
80 list, err := ParsePLSQLOmni(statement)

Callers 1

GenerateRestoreSQLFunction · 0.85

Calls 3

findFirstOracleDMLOnceFunction · 0.85
LenMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected