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

Function checkReturn

pkg/sql/sem/tree/overload.go:808–860  ·  view source on GitHub ↗

checkReturn checks the number of remaining overloaded function implementations. Returns ok=true if we should stop overload resolution, and returning either 1. the chosen overload in a slice, or 2. nil, along with the typed arguments. This modifies values within s as scratch slices, but only in the c

(
	ctx *SemaContext, s *typeCheckOverloadState,
)

Source from the content-addressed store, hash-verified

806// it returns true, which signals to the calling function that it should
807// immediately return, so any mutations to s are irrelevant.
808func checkReturn(
809 ctx *SemaContext, s *typeCheckOverloadState,
810) (ok bool, _ []TypedExpr, _ []overloadImpl, _ error) {
811 switch len(s.overloadIdxs) {
812 case 0:
813 if err := defaultTypeCheck(ctx, s, false); err != nil {
814 return false, nil, nil, err
815 }
816 return true, s.typedExprs, nil, nil
817
818 case 1:
819 idx := s.overloadIdxs[0]
820 o := s.overloads[idx]
821 p := o.params()
822 for _, i := range s.constIdxs {
823 des := p.GetAt(i)
824 typ, err := s.exprs[i].TypeCheck(ctx, des)
825 if err != nil {
826 return false, s.typedExprs, nil, pgerror.Wrapf(
827 err, pgcode.InvalidParameterValue,
828 "error type checking constant value",
829 )
830 }
831 if des != nil && !typ.ResolvedType().Equivalent(des) {
832 //return false, nil, nil, errors.AssertionFailedf(
833 // "desired constant value type %s but set type %s",
834 // log.Safe(des), log.Safe(typ.ResolvedType()),
835 //)
836 return false, nil, nil, errors.AssertionFailedf(
837 "desired constant value type %s but set type %s",
838 des, typ.ResolvedType(),
839 )
840 }
841 s.typedExprs[i] = typ
842 }
843
844 for _, i := range s.placeholderIdxs {
845 des := p.GetAt(i)
846 typ, err := s.exprs[i].TypeCheck(ctx, des)
847 if err != nil {
848 if des.IsAmbiguous() {
849 return false, nil, nil, nil
850 }
851 return false, nil, nil, err
852 }
853 s.typedExprs[i] = typ
854 }
855 return true, s.typedExprs, s.overloads[idx : idx+1], nil
856
857 default:
858 return false, nil, nil, nil
859 }
860}
861
862func formatCandidates(prefix string, candidates []overloadImpl) string {
863 var buf bytes.Buffer

Callers 2

typeCheckOverloadedExprsFunction · 0.85
filterAttemptFunction · 0.85

Calls 8

WrapfFunction · 0.92
defaultTypeCheckFunction · 0.85
EquivalentMethod · 0.80
IsAmbiguousMethod · 0.80
paramsMethod · 0.65
GetAtMethod · 0.65
TypeCheckMethod · 0.65
ResolvedTypeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…