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

Method TypeCheck

postgres/parser/sem/tree/type_check.go:470–500  ·  view source on GitHub ↗

TypeCheck implements the Expr interface.

(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
)

Source from the content-addressed store, hash-verified

468
469// TypeCheck implements the Expr interface.
470func (expr *IndirectionExpr) TypeCheck(
471 ctx context.Context, semaCtx *SemaContext, desired *types.T,
472) (TypedExpr, error) {
473 for i, t := range expr.Indirection {
474 if t.Slice {
475 return nil, unimplemented.NewWithIssuef(32551, "ARRAY slicing in %s", expr)
476 }
477 if i > 0 {
478 return nil, unimplemented.NewWithIssueDetailf(32552, "ind", "multidimensional indexing: %s", expr)
479 }
480
481 beginExpr, err := typeCheckAndRequire(ctx, semaCtx, t.Begin, types.Int, "ARRAY subscript")
482 if err != nil {
483 return nil, err
484 }
485 t.Begin = beginExpr
486 }
487
488 subExpr, err := expr.Expr.TypeCheck(ctx, semaCtx, types.MakeArray(desired))
489 if err != nil {
490 return nil, err
491 }
492 typ := subExpr.ResolvedType()
493 if typ.Family() != types.ArrayFamily {
494 return nil, pgerror.Newf(pgcode.DatatypeMismatch, "cannot subscript type %s because it is not an array", typ)
495 }
496 expr.Expr = subExpr
497 expr.typ = typ.ArrayContents()
498
499 return expr, nil
500}
501
502// TypeCheck implements the Expr interface.
503func (expr *AnnotateTypeExpr) TypeCheck(

Callers

nothing calls this directly

Calls 9

NewWithIssuefFunction · 0.92
NewWithIssueDetailfFunction · 0.92
MakeArrayFunction · 0.92
NewfFunction · 0.92
typeCheckAndRequireFunction · 0.85
FamilyMethod · 0.80
ArrayContentsMethod · 0.80
TypeCheckMethod · 0.65
ResolvedTypeMethod · 0.65

Tested by

no test coverage detected