Re: join of array

From: elein <elein(at)varlena(dot)com>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: elein <elein(at)varlena(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: join of array
Date: 2003-08-15 18:17:12
Message-ID: 20030815111712.G22348@cookie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

I guess I am arguing against the spec. :-)
But given the spec...
The spec is consistent in that it seems to
dereference the right operand one level.

However, that would still make 2b inconsistent
in the evaluation of the right operand.

> 1a) ARRAY[1,2] || ARRAY[3,4] == '{1,2,3,4}'
> 1b) ARRAY[[1],[2]] || ARRAY[[3],[4]] == '{{1},{2},{3},{4}}'
and ARRAY[1,2] || ARRAY[[3],[4]] == '{1,2,{3},{4}}'

> So by analogy the multidimensional variant is:
> 2b) ARRAY[[1],[2]] || ARRAY[3] == '{{1},{2},{3}}'
I would think this would be '{{1},{2}, 3}}'
and ARRAY[1,2] || ARRAY[[3],[4]] == '{1,2,{3},{4}}'

I do see the analogy you are making. But I
respectfully disagree (with the spec ?) that
the type/structure of the left operand should be
taken into account when evaluating the right operand.

elein

On Fri, Aug 15, 2003 at 10:36:54AM -0700, Joe Conway wrote:
> 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-08-15 18:24:01 Re: join of array
Previous Message Ron Johnson 2003-08-15 18:13:52 Arrays and "goodness" in RDBMSs (was Re: join of array)

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2003-08-15 18:24:01 Re: join of array
Previous Message Ron Johnson 2003-08-15 18:13:52 Arrays and "goodness" in RDBMSs (was Re: join of array)