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

Method TypeCheck

postgres/parser/sem/tree/type_check.go:529–549  ·  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

527
528// TypeCheck implements the Expr interface.
529func (expr *CollateExpr) TypeCheck(
530 ctx context.Context, semaCtx *SemaContext, desired *types.T,
531) (TypedExpr, error) {
532 _, err := language.Parse(expr.Locale)
533 if err != nil {
534 return nil, pgerror.Wrapf(err, pgcode.InvalidParameterValue,
535 "invalid locale %s", expr.Locale)
536 }
537 subExpr, err := expr.Expr.TypeCheck(ctx, semaCtx, types.String)
538 if err != nil {
539 return nil, err
540 }
541 t := subExpr.ResolvedType()
542 if types.IsStringType(t) || t.Family() == types.UnknownFamily {
543 expr.Expr = subExpr
544 expr.typ = types.MakeCollatedString(types.String, expr.Locale)
545 return expr, nil
546 }
547 return nil, pgerror.Newf(pgcode.DatatypeMismatch,
548 "incompatible type for COLLATE: %s", t)
549}
550
551// NewTypeIsNotCompositeError generates an error suitable to report
552// when a ColumnAccessExpr or TupleStar is applied to a non-composite

Callers

nothing calls this directly

Calls 8

WrapfFunction · 0.92
IsStringTypeFunction · 0.92
MakeCollatedStringFunction · 0.92
NewfFunction · 0.92
FamilyMethod · 0.80
TypeCheckMethod · 0.65
ResolvedTypeMethod · 0.65
ParseMethod · 0.45

Tested by

no test coverage detected