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

Function parseMySQLStatement

backend/plugin/parser/mysql/diagnose.go:31–58  ·  view source on GitHub ↗
(statement string)

Source from the content-addressed store, hash-verified

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

Callers 1

DiagnoseFunction · 0.85

Calls 3

ParseMySQLOmniFunction · 0.85
ByteOffsetToRunePositionFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected