MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / calcArrayOid

Function calcArrayOid

pkg/sql/types/oid.go:172–202  ·  view source on GitHub ↗

calcArrayOid returns the OID of the array type having elements of the given type.

(elemTyp *T)

Source from the content-addressed store, hash-verified

170// calcArrayOid returns the OID of the array type having elements of the given
171// type.
172func calcArrayOid(elemTyp *T) oid.Oid {
173 o := elemTyp.Oid()
174 switch elemTyp.Family() {
175 case ArrayFamily:
176 // Postgres nested arrays return the OID of the nested array (i.e. the
177 // OID doesn't change no matter how many levels of nesting there are),
178 // except in the special-case of the vector types.
179 switch o {
180 case oid.T_int2vector, oid.T_oidvector:
181 // Vector types have their own array OID types.
182 default:
183 return o
184 }
185
186 case UnknownFamily:
187 // Postgres doesn't have an OID for an array of unknown values, since
188 // it's not possible to create that in Postgres. But CRDB does allow that,
189 // so return 0 for that case (since there's no T__unknown). This is what
190 // previous versions of CRDB returned for this case.
191 return unknownArrayOid
192 }
193
194 // Map the OID of the array element type to the corresponding array OID.
195 // This should always be possible for all other OIDs (checked in oid.go
196 // init method).
197 o = oidToArrayOid[o]
198 if o == 0 {
199 panic(errors.AssertionFailedf("oid %d couldn't be mapped to array oid", o))
200 }
201 return o
202}

Callers 2

MakeArrayFunction · 0.85
upgradeTypeMethod · 0.85

Calls 2

OidMethod · 0.80
FamilyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…