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

Function PrependToMaybeNullArray

pkg/sql/sem/tree/eval.go:294–307  ·  view source on GitHub ↗

PrependToMaybeNullArray prepends an element in the front of an arrray. If the argument is NULL, an array of one element is created.

(typ *types.T, left Datum, right Datum)

Source from the content-addressed store, hash-verified

292// PrependToMaybeNullArray prepends an element in the front of an arrray.
293// If the argument is NULL, an array of one element is created.
294func PrependToMaybeNullArray(typ *types.T, left Datum, right Datum) (Datum, error) {
295 result := NewDArray(typ)
296 if err := result.Append(left); err != nil {
297 return nil, err
298 }
299 if right != DNull {
300 for _, e := range MustBeDArray(right).Array {
301 if err := result.Append(e); err != nil {
302 return nil, err
303 }
304 }
305 }
306 return result, nil
307}
308
309// TODO(justin): these might be improved by making arrays into an interface and
310// then introducing a ConcatenatedArray implementation which just references two

Callers

nothing calls this directly

Calls 3

AppendMethod · 0.95
NewDArrayFunction · 0.85
MustBeDArrayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…