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

Function initArrayElementConcatenation

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

TODO(justin): these might be improved by making arrays into an interface and then introducing a ConcatenatedArray implementation which just references two existing arrays. This would optimize the common case of appending an element (or array) to an array from O(n) to O(1).

()

Source from the content-addressed store, hash-verified

247// existing arrays. This would optimize the common case of appending an element
248// (or array) to an array from O(n) to O(1).
249func initArrayElementConcatenation() {
250 for _, t := range types.Scalar {
251 typ := t
252 BinOps[Concat] = append(BinOps[Concat], &BinOp{
253 LeftType: types.MakeArray(typ),
254 RightType: typ,
255 ReturnType: types.MakeArray(typ),
256 NullableArgs: true,
257 Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
258 return AppendToMaybeNullArray(typ, left, right)
259 },
260 })
261
262 BinOps[Concat] = append(BinOps[Concat], &BinOp{
263 LeftType: typ,
264 RightType: types.MakeArray(typ),
265 ReturnType: types.MakeArray(typ),
266 NullableArgs: true,
267 Fn: func(_ *EvalContext, left Datum, right Datum) (Datum, error) {
268 return PrependToMaybeNullArray(typ, left, right)
269 },
270 })
271 }
272}
273
274// ConcatArrays concatenates two arrays.
275func ConcatArrays(typ *types.T, left Datum, right Datum) (Datum, error) {

Callers 1

initFunction · 0.85

Calls 3

MakeArrayFunction · 0.92
AppendToMaybeNullArrayFunction · 0.85
PrependToMaybeNullArrayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…