From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: join of array |
Date: | 2003-08-15 15:34:14 |
Message-ID: | 3F3CFD76.5030300@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-patches |
Tom Lane wrote:
> Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz> writes:
>
>>Is possible merge two arrays like
>>array[1,2,3] + array[4,5,6] => array[1,2,3,4,5,6]
>
>
> I was about to say that || would do it, but I see that's not quite
> right:
>
> regression=# SELECT ARRAY[1,2,3] || ARRAY[4,5,6];
> ?column?
> -------------------
> {{1,2,3},{4,5,6}}
> (1 row)
>
> Offhand, I would think that '{1,2,3,4,5,6}' would be what I'd
> intuitively expect to get from "concatenating" these arrays.
> Joe, do we really have this implemented per spec?
>
Hmmm, it made sense to me, at at least at some point ;-). Here's the
SQL99 guidance (SQL200X doesn't give any more detailed guidance):
4.11.3.2 Operators that operate on array values and return array values
<array concatenation> is an operation that returns the array value made
by joining its array value operands in the order given.
So I guess it ought to be changed.
We also have
ARRAY[1,2] || 3 == '{1,2,3}'
and
ARRAY[[1,2],[3,4]] || ARRAY[5,6] == '{{1,2},{3,4},{5,6}}'
and
ARRAY[[1,2],[3,4]] || ARRAY[[1,2],[3,4]] ==
'{{{1,2},{3,4}},{{1,2},{3,4}}}'
I think the first two still make sense. I guess the third case ought to be:
ARRAY[[1,2],[3,4]] || ARRAY[[1,2],[3,4]] ==
'{{1,2},{3,4},{1,2},{3,4}}'
?
If this sounds good, I'll work on a patch for the behavior as well as
the docs.
Joe
From | Date | Subject | |
---|---|---|---|
Next Message | Rich Parker | 2003-08-15 15:35:11 | New to list, quick question. |
Previous Message | Andreas Pflug | 2003-08-15 15:33:21 | Re: [GENERAL] 7.4Beta |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-08-15 15:49:31 | Re: join of array |
Previous Message | Tom Lane | 2003-08-15 12:07:08 | Re: join of array |