MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / arrayOf

Function arrayOf

pkg/sql/parser/parse.go:499–517  ·  view source on GitHub ↗

arrayOf creates a type alias for an array of the given element type and fixed bounds. The bounds are currently ignored.

(
	ref tree.ResolvableTypeReference, bounds []int32,
)

Source from the content-addressed store, hash-verified

497// arrayOf creates a type alias for an array of the given element type and fixed
498// bounds. The bounds are currently ignored.
499func arrayOf(
500 ref tree.ResolvableTypeReference, bounds []int32,
501) (tree.ResolvableTypeReference, error) {
502 // If the reference is a statically known type, then return an array type,
503 // rather than an array type reference.
504 if typ, ok := tree.GetStaticallyKnownType(ref); ok {
505 switch typ.Family() {
506 case types.UnknownFamily, types.VoidFamily, types.TriggerFamily:
507 // Do not allow arrays of these types. This is consistent with Postgres'
508 // behavior.
509 return nil, pgerror.Newf(pgcode.UndefinedObject, "type %s[] does not exist", typ.Name())
510 }
511 if err := types.CheckArrayElementType(typ); err != nil {
512 return nil, err
513 }
514 return types.MakeArray(typ), nil
515 }
516 return &tree.ArrayTypeReference{ElementType: ref}, nil
517}
518
519// ParseDoBlockFn allows the SQL parser to parse a PL/pgSQL DO block body.
520var ParseDoBlockFn func(tree.DoBlockOptions) (tree.DoBlockBody, error)

Callers

nothing calls this directly

Calls 6

GetStaticallyKnownTypeFunction · 0.92
NewfFunction · 0.92
CheckArrayElementTypeFunction · 0.92
MakeArrayFunction · 0.92
FamilyMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…