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

Function recursiveDeserializeType

server/types/serialization.go:260–282  ·  view source on GitHub ↗

recursiveDeserializeType handles recursive type initialization by caching the type-in-progress and returning the target type. This also takes a TypeCollection so that it may be reused if multiple calls are made without having to fetch it at each instance.

(ctx *sql.Context, typ *DoltgresType, typeColl TypeCollection, target *DoltgresType)

Source from the content-addressed store, hash-verified

258// target type. This also takes a TypeCollection so that it may be reused if multiple calls are made without having to
259// fetch it at each instance.
260func recursiveDeserializeType(ctx *sql.Context, typ *DoltgresType, typeColl TypeCollection, target *DoltgresType) (*DoltgresType, TypeCollection, error) {
261 if !target.IsUnresolved {
262 return target, typeColl, nil
263 }
264 var recursedType *DoltgresType
265 var err error
266 if typeColl == nil {
267 typeColl, err = GetTypesCollectionFromContext(ctx, "")
268 if err != nil {
269 return nil, nil, err
270 }
271 }
272 typeColl.WithCachedType(typ, func() {
273 t, nErr := typeColl.GetType(ctx, target.ID)
274 recursedType = t
275 err = nErr
276 })
277 // `GetType` returns a nil type if it cannot be found, so we want to error in that case
278 if err == nil && recursedType == nil {
279 return target, typeColl, errors.Errorf("unable to resolve type `%s` during deserialization", target.ID.TypeName())
280 }
281 return recursedType, typeColl, err
282}

Callers 1

DeserializeTypeFunction · 0.85

Calls 5

TypeNameMethod · 0.80
WithCachedTypeMethod · 0.65
GetTypeMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected