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

Method Add

server/functions/framework/overloads.go:44–60  ·  view source on GitHub ↗

Add adds the given function to the overload collection. Returns an error if the there's a problem with the function's declaration.

(function FunctionInterface)

Source from the content-addressed store, hash-verified

42// Add adds the given function to the overload collection. Returns an error if the there's a problem with the
43// function's declaration.
44func (o *Overloads) Add(function FunctionInterface) error {
45 key := keyForParamTypes(function.GetParameters())
46 if _, ok := o.ByParamType[key]; ok {
47 return errors.Errorf("duplicate function overload for `%s`", function.GetName())
48 }
49
50 if function.VariadicIndex() >= 0 {
51 varArgsType := function.GetParameters()[function.VariadicIndex()]
52 if !varArgsType.IsArrayType() {
53 return errors.Errorf("variadic parameter must be an array type for function `%s`", function.GetName())
54 }
55 }
56
57 o.ByParamType[key] = function
58 o.AllOverloads = append(o.AllOverloads, function)
59 return nil
60}
61
62// keyForParamTypes returns a string key to match an overload with the given parameter types.
63func keyForParamTypes(types []*pgtypes.DoltgresType) string {

Callers 15

ResolveProcedureDefaultsFunction · 0.95
FunctionMethod · 0.95
compileAggFunctionFunction · 0.95
resultForDefaultIterMethod · 0.45
CreateDefaultRoleFunction · 0.45
timezone.goFile · 0.45
getTimeFunction · 0.45
numericGenerateSeriesFunction · 0.45
generate_series.goFile · 0.45
compileFunctionsFunction · 0.45
interval_pl_callableFunction · 0.45

Calls 6

keyForParamTypesFunction · 0.85
IsArrayTypeMethod · 0.80
GetParametersMethod · 0.65
ErrorfMethod · 0.65
GetNameMethod · 0.65
VariadicIndexMethod · 0.65

Tested by

no test coverage detected