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

Function CreateArrayTypeFromBaseType

server/types/array.go:30–82  ·  view source on GitHub ↗

CreateArrayTypeFromBaseType create array type from given type. This also sets the `Array` on the given base type if it has not already been set.

(baseType *DoltgresType)

Source from the content-addressed store, hash-verified

28// CreateArrayTypeFromBaseType create array type from given type. This also sets the `Array` on the given base type if
29// it has not already been set.
30func CreateArrayTypeFromBaseType(baseType *DoltgresType) *DoltgresType {
31 align := TypeAlignment_Int
32 if baseType.Align == TypeAlignment_Double {
33 align = TypeAlignment_Double
34 }
35 var arrayID id.Type
36 if baseType.Array == nil || baseType.Array == internalNullType || baseType.Array.ID == id.NullType {
37 arrayID = id.NewType(baseType.ID.SchemaName(), "_"+baseType.ID.TypeName())
38 } else {
39 arrayID = baseType.Array.ID
40 }
41 arrayType := &DoltgresType{
42 ID: arrayID,
43 TypLength: int16(-1),
44 PassedByVal: false,
45 TypType: TypeType_Base,
46 TypCategory: TypeCategory_ArrayTypes,
47 IsPreferred: false,
48 IsDefined: true,
49 Delimiter: ",",
50 RelID: id.Null,
51 SubscriptFunc: toFuncID("array_subscript_handler", toInternal("internal")),
52 Elem: baseType,
53 Array: internalNullType,
54 InputFunc: toFuncID("array_in", toInternal("cstring"), toInternal("oid"), toInternal("int4")),
55 OutputFunc: toFuncID("array_out", toInternal("anyarray")),
56 ReceiveFunc: toFuncID("array_recv", toInternal("internal"), toInternal("oid"), toInternal("int4")),
57 SendFunc: toFuncID("array_send", toInternal("anyarray")),
58 ModInFunc: baseType.ModInFunc,
59 ModOutFunc: baseType.ModOutFunc,
60 AnalyzeFunc: toFuncID("array_typanalyze", toInternal("internal")),
61 Align: align,
62 Storage: TypeStorage_Extended,
63 NotNull: false,
64 BaseTypeType: internalNullType,
65 TypMod: -1,
66 NDims: 0,
67 TypCollation: baseType.TypCollation,
68 DefaulBin: "",
69 Default: "",
70 Acl: nil,
71 Checks: nil,
72 InternalName: fmt.Sprintf("%s[]", baseType.Name()), // This will be set to the proper name in ToArrayType
73 attTypMod: baseType.attTypMod, // TODO: check
74 CompareFunc: toFuncID("btarraycmp", toInternal("anyarray"), toInternal("anyarray")),
75 SerializationFunc: serializeTypeArray,
76 DeserializationFunc: deserializeTypeArray,
77 }
78 if baseType.Array == nil || baseType.Array == internalNullType || baseType.Array.ID == id.NullType {
79 baseType.Array = arrayType
80 }
81 return arrayType
82}
83
84// serializeTypeArray handles serialization from the standard representation to our serialized representation that is
85// written in Dolt.

Callers 15

RowIterMethod · 0.92
regclass_array.goFile · 0.85
timetz_array.goFile · 0.85
timestamp_array.goFile · 0.85
time_array.goFile · 0.85
int32_array.goFile · 0.85
char_array.goFile · 0.85
numeric_array.goFile · 0.85
interval_array.goFile · 0.85
json_array.goFile · 0.85
oid_array.goFile · 0.85

Calls 6

NewTypeFunction · 0.92
toFuncIDFunction · 0.85
toInternalFunction · 0.85
TypeNameMethod · 0.80
NameMethod · 0.65
SchemaNameMethod · 0.45

Tested by

no test coverage detected