parsePingCapSingleStatement runs the native pingcap parser on a single pre-split base.Statement and applies line-tracking. Mirrors the per-loop body of ParseTiDBForSyntaxCheck so the dispatcher's pingcap-fallback path produces *AST values structurally identical to the canonical pre-flip path (un-mig
(singleSQL base.Statement)
| 133 | // - (nil, err) on a hard parser error, with the syntax error's line |
| 134 | // adjusted to absolute coordinates. |
| 135 | func parsePingCapSingleStatement(singleSQL base.Statement) (*AST, error) { |
| 136 | p := newTiDBParser() |
| 137 | nodes, _, err := p.Parse(singleSQL.Text, "", "") |
| 138 | if err != nil { |
| 139 | syntaxErr := convertParserError(err) |
| 140 | if se, ok := syntaxErr.(*base.SyntaxError); ok && se.Position != nil { |
| 141 | se.Position.Line = int32(singleSQL.BaseLine()) + se.Position.Line |
| 142 | } |
| 143 | return nil, syntaxErr |
| 144 | } |
| 145 | if len(nodes) != 1 { |
| 146 | return nil, nil |
| 147 | } |
| 148 | node := nodes[0] |
| 149 | actualStartLine, err := applyTiDBLineTracking(node, singleSQL.BaseLine(), singleSQL.Text) |
| 150 | if err != nil { |
| 151 | return nil, err |
| 152 | } |
| 153 | return &AST{ |
| 154 | StartPosition: &storepb.Position{Line: int32(actualStartLine)}, |
| 155 | Node: node, |
| 156 | }, nil |
| 157 | } |
| 158 | |
| 159 | // convertOmniParseError mirrors mysql.go's convertOmniError: takes an omni |
| 160 | // parser error and produces a base.SyntaxError with absolute line/column |