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

Function convertParserError

backend/plugin/parser/tidb/tidb.go:129–150  ·  view source on GitHub ↗
(parserErr error)

Source from the content-addressed store, hash-verified

127)
128
129func convertParserError(parserErr error) error {
130 // line 1 column 15 near "TO world;"
131 res := lineColumnRegex.FindAllStringSubmatch(parserErr.Error(), -1)
132 if len(res) != 1 {
133 return parserErr
134 }
135 if len(res[0]) != 3 {
136 return parserErr
137 }
138 line, err := strconv.ParseInt(res[0][1], 10, 32)
139 if err != nil {
140 return parserErr
141 }
142 column, err := strconv.ParseInt(res[0][2], 10, 32)
143 if err != nil {
144 return parserErr
145 }
146 return &base.SyntaxError{
147 Position: common.ConvertTiDBParserErrorPositionToPosition(int32(line), int32(column)),
148 Message: parserErr.Error(),
149 }
150}
151
152// SetLineForMySQLCreateTableStmt sets the line for columns and table constraints in MySQL CREATE TABLE statments.
153// This is a temporary function. Because we do not convert tidb AST to our AST. So we have to implement this.

Callers 2

ParseTiDBFunction · 0.85

Calls 2

ErrorMethod · 0.45

Tested by

no test coverage detected