Re: join of array - Mailing list pgsql-general

From Joe Conway
Subject Re: join of array
Date
Msg-id 3F3D1A36.3000808@joeconway.com
Whole thread Raw
In response to Re: join of array  (elein <elein@varlena.com>)
Responses Re: join of array  (elein <elein@varlena.com>)
List pgsql-general
elein wrote:
> you said we had:
>
>>We also have
      ^^^^

There are two variants each of two cases. The first case is what started
this discussion. The newest reading of the SQL99 spec says that we
*must* do this:
1a)  ARRAY[1,2] || ARRAY[3,4] == '{1,2,3,4}'

Quoting the paragraph provided by Tom:
"c) Otherwise, the result is the array comprising every element
     of AV1 followed by every element of AV2."

The variant is that when you have an "array of arrays", i.e. a
multidimensional array (which Peter E pointed out earlier is part of
SQL99 too), the spec wording implies that we also *must* do this:
1b)  ARRAY[[1],[2]] || ARRAY[[3],[4]] == '{{1},{2},{3},{4}'


The second case is not directly addressed by the spec as far as I can
see, i.e. it is a Postgres extension. That is:
2a)  ARRAY[1,2] || 3 == '{1,2,3}'

So by analogy the multidimensional variant is:
2b)  ARRAY[[1],[2]] || ARRAY[3] == '{{1},{2},{3}}'

Cases 1a and 1b are currently wrong according to the spec., and that's
the change we've been discussing. Cases 2a and 2b currently work as
shown and are correct IMHO (although Tom pointed out a lower bound index
issue that I'll address in my response to him).

Does this help?

Joe


pgsql-general by date:

Previous
From: Franco Bruno Borghesi
Date:
Subject: Re: New to list, quick question.
Next
From: Joe Conway
Date:
Subject: Re: join of array