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

Method TypModIn

server/types/type.go:1027–1040  ·  view source on GitHub ↗

TypModIn encodes given text array value to type modifier in int32 format.

(ctx *sql.Context, val []any)

Source from the content-addressed store, hash-verified

1025
1026// TypModIn encodes given text array value to type modifier in int32 format.
1027func (t *DoltgresType) TypModIn(ctx *sql.Context, val []any) (int32, error) {
1028 if t.ModInFunc == 0 {
1029 return 0, errors.Errorf("typmodin function for type '%s' doesn't exist", t.Name())
1030 }
1031 o, err := globalFunctionRegistry.GetFunction(ctx, t.ModInFunc).CallVariadic(ctx, val)
1032 if err != nil {
1033 return 0, err
1034 }
1035 output, ok := o.(int32)
1036 if !ok {
1037 return 0, errors.Errorf(`expected int32, got %T`, output)
1038 }
1039 return output, nil
1040}
1041
1042// TypModOut decodes type modifier in int32 format to string representation of it.
1043func (t *DoltgresType) TypModOut(ctx *sql.Context, val int32) (string, error) {

Callers

nothing calls this directly

Calls 4

NameMethod · 0.95
ErrorfMethod · 0.65
CallVariadicMethod · 0.65
GetFunctionMethod · 0.45

Tested by

no test coverage detected