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

Function AppendToMaybeNullArray

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

AppendToMaybeNullArray appends an element to an array. If the first 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

211// AppendToMaybeNullArray appends an element to an array. If the first
212// argument is NULL, an array of one element is created.
213func AppendToMaybeNullArray(typ *types.T, left Datum, right Datum) (Datum, error) {
214 result := NewDArray(typ)
215 if left != DNull {
216 for _, e := range MustBeDArray(left).Array {
217 if err := result.Append(e); err != nil {
218 return nil, err
219 }
220 }
221 }
222 if err := result.Append(right); err != nil {
223 return nil, err
224 }
225 return result, nil
226}
227
228// PrependToMaybeNullArray prepends an element in the front of an arrray.
229// If the argument is NULL, an array of one element is created.

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…