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

Function typeCheckAndRequireTupleElems

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

typeCheckAndRequireTupleElems asserts that all elements in the Tuple are comparable to the input Expr given the input comparison operator.

(
	ctx context.Context, semaCtx *SemaContext, expr TypedExpr, tuple *Tuple, op ComparisonOperator,
)

Source from the content-addressed store, hash-verified

1649// typeCheckAndRequireTupleElems asserts that all elements in the Tuple are
1650// comparable to the input Expr given the input comparison operator.
1651func typeCheckAndRequireTupleElems(
1652 ctx context.Context, semaCtx *SemaContext, expr TypedExpr, tuple *Tuple, op ComparisonOperator,
1653) (TypedExpr, error) {
1654 tuple.typ = types.MakeTuple(make([]*types.T, len(tuple.Exprs)))
1655 for i, subExpr := range tuple.Exprs {
1656 // Require that the sub expression is comparable to the required type.
1657 _, rightTyped, _, _, err := typeCheckComparisonOp(ctx, semaCtx, op, expr, subExpr)
1658 if err != nil {
1659 return nil, err
1660 }
1661 tuple.Exprs[i] = rightTyped
1662 tuple.typ.TupleContents()[i] = rightTyped.ResolvedType()
1663 }
1664 return tuple, nil
1665}
1666
1667func typeCheckAndRequireBoolean(
1668 ctx context.Context, semaCtx *SemaContext, expr Expr, op string,

Callers 1

Calls 4

MakeTupleFunction · 0.92
typeCheckComparisonOpFunction · 0.85
TupleContentsMethod · 0.80
ResolvedTypeMethod · 0.65

Tested by

no test coverage detected