Re: SQL99 ARRAY support proposal - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: SQL99 ARRAY support proposal
Date
Msg-id 1047588865.1709.4.camel@fuji.krosing.net
Whole thread Raw
In response to Re: SQL99 ARRAY support proposal  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: SQL99 ARRAY support proposal
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Upgrading the backend's error-message infrastructure
Next
From: Tom Lane
Date:
Subject: Re: SQL99 ARRAY support proposal