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

Function ensureExpectedType

pkg/sql/sem/tree/eval.go:4120–4127  ·  view source on GitHub ↗

ensureExpectedType will return an error if a datum does not match the provided type. If the expected type is Any or if the datum is a Null type, then no error will be returned.

(exp *types.T, d Datum)

Source from the content-addressed store, hash-verified

4118// provided type. If the expected type is Any or if the datum is a Null
4119// type, then no error will be returned.
4120func ensureExpectedType(exp *types.T, d Datum) error {
4121 if !(exp.Family() == types.AnyFamily || d.ResolvedType().Family() == types.UnknownFamily ||
4122 d.ResolvedType().Equivalent(exp)) {
4123 return errors.AssertionFailedf(
4124 "expected return type %q, got: %q", errors.Safe(exp), errors.Safe(d.ResolvedType()))
4125 }
4126 return nil
4127}
4128
4129// Eval implements the TypedExpr interface.
4130func (expr *IfErrExpr) Eval(ctx *EvalContext) (Datum, error) {

Callers 3

EvalMethod · 0.85
EvalMethod · 0.85
EvalMethod · 0.85

Calls 3

FamilyMethod · 0.80
EquivalentMethod · 0.80
ResolvedTypeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…