MCPcopy Create free account
hub / github.com/dolthub/doltgresql / ParseType

Function ParseType

postgres/parser/parser/parse.go:377–389  ·  view source on GitHub ↗

ParseType parses a column type.

(sql string)

Source from the content-addressed store, hash-verified

375
376// ParseType parses a column type.
377func ParseType(sql string) (tree.ResolvableTypeReference, error) {
378 expr, err := ParseExpr(fmt.Sprintf("1::%s", sql))
379 if err != nil {
380 return nil, err
381 }
382
383 cast, ok := expr.(*tree.CastExpr)
384 if !ok {
385 return nil, errors.AssertionFailedf("expected a tree.CastExpr, but found %T", expr)
386 }
387
388 return cast.Type, nil
389}
390
391var errBitLengthNotPositive = pgerror.WithCandidateCode(
392 errors.New("length for type bit must be at least 1"), pgcode.InvalidParameterValue)

Callers 2

nodeCreateFunctionFunction · 0.92
nodeCreateProcedureFunction · 0.92

Calls 1

ParseExprFunction · 0.85

Tested by

no test coverage detected