Re: SQL99 ARRAY support proposal

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Joe Conway <mail(at)joeconway(dot)com>, "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SQL99 ARRAY support proposal
Date: 2003-03-13 20:54:25
Message-ID: 1047588865.1709.4.camel@fuji.krosing.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane kirjutas N, 13.03.2003 kell 19:12:
> Peter Eisentraut <peter_e(at)gmx(dot)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 TRUE if left array is contained
in right array
# int[] - return the number of elements in array
int[] + int - push element to array ( add to end of array)
int[] + int[] - merge of arrays (right array added to 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[] - returns intarray as a union of two arrays
int[] & int[] - returns intersection of arrays
int[] @@ query_int - returns TRUE if array satisfies query
(like '1&(2|3)')
query_int ~~ int[] - -/-

-----------------
Hannu

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-03-13 21:03:52 Re: SQL99 ARRAY support proposal
Previous Message Tom Lane 2003-03-13 20:51:00 Upgrading the backend's error-message infrastructure

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2003-03-13 21:03:52 Re: SQL99 ARRAY support proposal
Previous Message Rod Taylor 2003-03-13 19:32:28 Re: SQL99 ARRAY support proposal