(statement string)
| 29 | } |
| 30 | |
| 31 | func 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 | } |
no test coverage detected