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

Method Serialize

core/procedures/serialization.go:28–63  ·  view source on GitHub ↗

Serialize returns the Procedure as a byte slice. If the Procedure is invalid, then this returns a nil slice.

(ctx context.Context)

Source from the content-addressed store, hash-verified

26
27// Serialize returns the Procedure as a byte slice. If the Procedure is invalid, then this returns a nil slice.
28func (procedure Procedure) Serialize(ctx context.Context) ([]byte, error) {
29 if !procedure.ID.IsValid() {
30 return nil, nil
31 }
32
33 // Write all of the procedures to the writer
34 writer := utils.NewWriter(256)
35 writer.VariableUint(1) // Version
36 // Write the procedure data
37 writer.Id(procedure.ID.AsId())
38 writer.StringSlice(procedure.ParameterNames)
39 writer.IdTypeSlice(procedure.ParameterTypes)
40 writer.String(procedure.Definition)
41 writer.String(procedure.ExtensionName)
42 writer.String(procedure.ExtensionSymbol)
43 writer.String(procedure.SQLDefinition)
44 // Write the parameter modes
45 writer.VariableUint(uint64(len(procedure.ParameterModes)))
46 for _, mode := range procedure.ParameterModes {
47 writer.Uint8(uint8(mode))
48 }
49 // Write the operations
50 writer.VariableUint(uint64(len(procedure.Operations)))
51 for _, op := range procedure.Operations {
52 writer.Uint16(uint16(op.OpCode))
53 writer.String(op.PrimaryData)
54 writer.StringSlice(op.SecondaryData)
55 writer.String(op.Target)
56 writer.Int32(int32(op.Index))
57 writer.StringMap(op.Options)
58 }
59 // Write version 1 data
60 writer.StringSlice(procedure.ParameterDefaults)
61 // Returns the data
62 return writer.Data(), nil
63}
64
65// DeserializeProcedure returns the Procedure that was serialized in the byte slice. Returns an empty Procedure (invalid
66// ID) if data is nil or empty.

Callers 1

HashOfMethod · 0.95

Calls 13

VariableUintMethod · 0.95
IdMethod · 0.95
StringSliceMethod · 0.95
IdTypeSliceMethod · 0.95
StringMethod · 0.95
Uint8Method · 0.95
Uint16Method · 0.95
Int32Method · 0.95
StringMapMethod · 0.95
DataMethod · 0.95
NewWriterFunction · 0.92
IsValidMethod · 0.45

Tested by

no test coverage detected