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

Function parseMariaDBStatement

backend/plugin/parser/mariadb/diagnose.go:29–56  ·  view source on GitHub ↗
(statement string)

Source from the content-addressed store, hash-verified

27}
28
29func parseMariaDBStatement(statement string) *base.SyntaxError {
30 trimmedStatement := strings.TrimRightFunc(statement, unicode.IsSpace)
31 if len(trimmedStatement) > 0 && !strings.HasSuffix(trimmedStatement, ";") {
32 // Add a semicolon to the end of the statement to allow users to omit the semicolon
33 // for the last statement in the script.
34 statement += ";"
35 }
36
37 _, err := ParseMariaDBOmni(statement)
38 if err == nil {
39 return nil
40 }
41
42 var parseErr *mariadbomniparser.ParseError
43 if !errors.As(err, &parseErr) {
44 return &base.SyntaxError{
45 Position: &storepb.Position{Line: 1, Column: 1},
46 Message: err.Error(),
47 }
48 }
49
50 pos := ByteOffsetToRunePosition(statement, parseErr.Position)
51 return &base.SyntaxError{
52 Position: pos,
53 Message: parseErr.Message,
54 RawMessage: parseErr.Message,
55 }
56}

Callers 1

DiagnoseFunction · 0.85

Calls 3

ParseMariaDBOmniFunction · 0.85
ByteOffsetToRunePositionFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected