parseMySQLStatements is the ParseStatementsFunc for MySQL, MariaDB, and OceanBase. Returns []ParsedStatement with both text and AST populated.
(statement string)
| 22 | // parseMySQLStatements is the ParseStatementsFunc for MySQL, MariaDB, and OceanBase. |
| 23 | // Returns []ParsedStatement with both text and AST populated. |
| 24 | func parseMySQLStatements(statement string) ([]base.ParsedStatement, error) { |
| 25 | // Split once to get Statement with text and positions |
| 26 | stmts, err := SplitSQL(statement) |
| 27 | if err != nil { |
| 28 | return nil, err |
| 29 | } |
| 30 | |
| 31 | var result []base.ParsedStatement |
| 32 | for _, stmt := range stmts { |
| 33 | if stmt.Empty { |
| 34 | continue |
| 35 | } |
| 36 | |
| 37 | list, omniErr := ParseMySQLOmni(stmt.Text) |
| 38 | if omniErr != nil { |
| 39 | return nil, convertOmniError(omniErr, stmt) |
| 40 | } |
| 41 | |
| 42 | if list == nil || len(list.Items) == 0 { |
| 43 | continue |
| 44 | } |
| 45 | |
| 46 | for _, node := range list.Items { |
| 47 | result = append(result, base.ParsedStatement{ |
| 48 | Statement: stmt, |
| 49 | AST: &OmniAST{ |
| 50 | Node: node, |
| 51 | Text: stmt.Text, |
| 52 | StartPosition: stmt.Start, |
| 53 | }, |
| 54 | }) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | return result, nil |
| 59 | } |
| 60 | |
| 61 | // convertOmniError converts an omni parser error to a base.SyntaxError with proper line:column position. |
| 62 | func convertOmniError(err error, stmt base.Statement) error { |
nothing calls this directly
no test coverage detected