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

Function PrependToMaybeNullArray

pkg/sql/sem/tree/eval.go:230–243  ·  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

228// PrependToMaybeNullArray prepends an element in the front of an arrray.
229// If the argument is NULL, an array of one element is created.
230func PrependToMaybeNullArray(typ *types.T, left Datum, right Datum) (Datum, error) {
231 result := NewDArray(typ)
232 if err := result.Append(left); err != nil {
233 return nil, err
234 }
235 if right != DNull {
236 for _, e := range MustBeDArray(right).Array {
237 if err := result.Append(e); err != nil {
238 return nil, err
239 }
240 }
241 }
242 return result, nil
243}
244
245// TODO(justin): these might be improved by making arrays into an interface and
246// then introducing a ConcatenatedArray implementation which just references two

Callers 1

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…