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

Function DeserializeType

server/types/serialization.go:49–175  ·  view source on GitHub ↗

DeserializeType is able to deserialize the given serialized type into an appropriate extended type. All extended types will be defined by DoltgreSQL.

(ctx *sql.Context, serializedType []byte)

Source from the content-addressed store, hash-verified

47// DeserializeType is able to deserialize the given serialized type into an appropriate extended type. All extended
48// types will be defined by DoltgreSQL.
49func DeserializeType(ctx *sql.Context, serializedType []byte) (sql.ExtendedType, error) {
50 if len(serializedType) == 0 {
51 return nil, errors.Errorf("deserializing empty type data")
52 }
53
54 typ := &DoltgresType{}
55 var typeColl TypeCollection
56 reader := utils.NewReader(serializedType)
57 version := reader.VariableUint()
58 if version != 0 {
59 return nil, errors.Errorf("version %d of types is not supported, please upgrade the server", version)
60 }
61
62 typ.ID = id.Type(reader.Id())
63 typ.TypLength = reader.Int16()
64 typ.PassedByVal = reader.Bool()
65 typ.TypType = TypeType(reader.String())
66 typ.TypCategory = TypeCategory(reader.String())
67 typ.IsPreferred = reader.Bool()
68 typ.IsDefined = reader.Bool()
69 typ.Delimiter = reader.String()
70 typ.RelID = reader.Id()
71 typ.SubscriptFunc = globalFunctionRegistry.InternalToRegistryID(id.Function(reader.Id()))
72 typ.Elem = prefillTypeDuringDeserialization(id.Type(reader.Id()))
73 typ.Array = prefillTypeDuringDeserialization(id.Type(reader.Id()))
74 typ.InputFunc = globalFunctionRegistry.InternalToRegistryID(id.Function(reader.Id()))
75 typ.OutputFunc = globalFunctionRegistry.InternalToRegistryID(id.Function(reader.Id()))
76 receiveFunc := id.Function(reader.Id())
77 typ.ReceiveFunc = globalFunctionRegistry.InternalToRegistryID(receiveFunc)
78 sendFunc := id.Function(reader.Id())
79 typ.SendFunc = globalFunctionRegistry.InternalToRegistryID(sendFunc)
80 typ.ModInFunc = globalFunctionRegistry.InternalToRegistryID(id.Function(reader.Id()))
81 typ.ModOutFunc = globalFunctionRegistry.InternalToRegistryID(id.Function(reader.Id()))
82 typ.AnalyzeFunc = globalFunctionRegistry.InternalToRegistryID(id.Function(reader.Id()))
83 typ.Align = TypeAlignment(reader.String())
84 typ.Storage = TypeStorage(reader.String())
85 typ.NotNull = reader.Bool()
86 typ.BaseTypeType = prefillTypeDuringDeserialization(id.Type(reader.Id()))
87 typ.TypMod = reader.Int32()
88 typ.NDims = reader.Int32()
89 typ.TypCollation = id.Collation(reader.Id())
90 typ.DefaulBin = reader.String()
91 typ.Default = reader.String()
92 numOfAcl := reader.VariableUint()
93 for k := uint64(0); k < numOfAcl; k++ {
94 ac := reader.String()
95 typ.Acl = append(typ.Acl, ac)
96 }
97 numOfChecks := reader.VariableUint()
98 for k := uint64(0); k < numOfChecks; k++ {
99 checkName := reader.String()
100 checkExpr := reader.String()
101 typ.Checks = append(typ.Checks, &sql.CheckDefinition{
102 Name: checkName,
103 CheckExpression: checkExpr,
104 Enforced: true,
105 })
106 }

Callers 1

Calls 15

VariableUintMethod · 0.95
IdMethod · 0.95
Int16Method · 0.95
BoolMethod · 0.95
StringMethod · 0.95
Int32Method · 0.95
Float32Method · 0.95
IsEmptyMethod · 0.95
NameMethod · 0.95
NewReaderFunction · 0.92
TypeTypeAlias · 0.92
FunctionTypeAlias · 0.92

Tested by 1