MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / ParseType

Function ParseType

pkg/sql/parser/parse.go:301–313  ·  view source on GitHub ↗

ParseType parses a column type.

(sql string)

Source from the content-addressed store, hash-verified

299
300// ParseType parses a column type.
301func ParseType(sql string) (*types.T, error) {
302 expr, err := ParseExpr(fmt.Sprintf("1::%s", sql))
303 if err != nil {
304 return nil, err
305 }
306
307 cast, ok := expr.(*tree.CastExpr)
308 if !ok {
309 return nil, errors.AssertionFailedf("expected a tree.CastExpr, but found %T", expr)
310 }
311
312 return cast.Type, nil
313}
314
315var errBitLengthNotPositive = pgerror.WithCandidateCode(
316 errors.New("length for type bit must be at least 1"), pgcode.InvalidParameterValue)

Callers

nothing calls this directly

Calls 1

ParseExprFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…