Tom Lane kirjutas N, 13.03.2003 kell 19:12:
> Peter Eisentraut <peter_e@gmx.net> writes:
> > OK, let's look at these more closely:
>
> >> array_push(anyarray, anyelement) returns anyarray
>
> > The standard spelling for that appears to be
> > somearray || ARRAY[element]
> > which also has the nice property that it is commutative.
>
> Sure ... but that just means that || is the operator name for the
> underlying array_push function. We still need a way to declare this
> operation as a function.
I think he mant that you just need to conacat for too arrays, no need
for single-element push/append. OTOH a separate push may be more
efficient
contrib/intarray has the following functions (note that they use + for
|| above)
OPERATIONS:
int[] && int[] - overlap - returns TRUE if arrays has at least one common elements. int[] @ int[]
-contains - returns TRUE if left array contains right array int[] ~ int[] - contained - returns
TRUEif left array is contained in right array # int[] - return the number of elements in
arrayint[] + int - push element to array ( add to end of array) int[] + int[] - merge of arrays (right array
addedto the end of left one) int[] - int - remove entries matched by right argument from array
int[]- int[] - remove right array from left int[] | int - returns intarray - union of arguments int[] | int[] -
returnsintarray as a union of two arrays int[] & int[] - returns intersection of arrays int[] @@ query_int - returns
TRUEif array satisfies query (like '1&(2|3)') query_int ~~ int[] - -/-
-----------------
Hannu