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

Function DeserializeExtension

core/extensions/serialization.go:47–68  ·  view source on GitHub ↗

DeserializeExtension returns the Extension that was serialized in the byte slice. Returns an empty Extension (has an invalid ID) if data is nil or empty.

(ctx context.Context, data []byte)

Source from the content-addressed store, hash-verified

45// DeserializeExtension returns the Extension that was serialized in the byte slice. Returns an empty Extension (has an
46// invalid ID) if data is nil or empty.
47func DeserializeExtension(ctx context.Context, data []byte) (Extension, error) {
48 if len(data) == 0 {
49 return Extension{}, nil
50 }
51 reader := utils.NewReader(data)
52 version := reader.VariableUint()
53 if version != 0 {
54 return Extension{}, errors.Errorf("version %d of extensions are not supported, please upgrade the server", version)
55 }
56
57 // Read from the reader
58 ext := Extension{}
59 ext.ExtName = id.Extension(reader.Id())
60 ext.Namespace = id.Namespace(reader.Id())
61 ext.Relocatable = reader.Bool()
62 ext.LibIdentifier = LibraryIdentifier(reader.String())
63 if !reader.IsEmpty() {
64 return Extension{}, errors.Errorf("extra data found while deserializing an extension")
65 }
66 // Return the deserialized object
67 return ext, nil
68}

Callers 2

DeserializeRootObjectMethod · 0.85
reloadCachesMethod · 0.85

Calls 10

VariableUintMethod · 0.95
IdMethod · 0.95
BoolMethod · 0.95
StringMethod · 0.95
IsEmptyMethod · 0.95
NewReaderFunction · 0.92
ExtensionTypeAlias · 0.92
NamespaceTypeAlias · 0.92
LibraryIdentifierTypeAlias · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected