Joe Conway wrote:
> Tom Lane wrote:
> > I think he's got a good point, actually. We document the ARRAY-with-
> > parens-around-a-SELECT syntax as
> >
> > The resulting one-dimensional array will have an element for
> > each row in the subquery result, with an element type matching
> > that of the subquery's output column.
> >
> > To me, that implies that a subquery result of no rows generates a
> > one-dimensional array of no elements, not a null array.
>
> OK, looks like I'm outnumbered.
>
> But as far as I know, we have never had a way to produce a
> one-dimensional empty array. Empty arrays thus far have been dimensionless.
>
> Assuming we really want an empty 1D array, I created the attached patch.
> This works fine, but now leaves a few oddities to be dealt with, e.g.:
>
> regression=# select array_dims(array(select 1 where false));
> array_dims
> ------------
> [1:0]
> (1 row)
>
> Any thoughts on how this should be handled for an empty 1D array?
>
> > The point Markus is complaining about seems like it should
> > be easily fixable.
>
> Well, "easily" is a relative term. My Postgres hacking neurons have
> gotten kind of rusty lately -- but then maybe that was your underlying
> point ;-)
No one responed to this email, so I will try. Is this the one
dimmentional array you were talking about?
test=> select array_dims('{}'::integer[]); array_dims------------(1 row)
Why is [1:0] wrong to return?
-- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610)
359-1001+ If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square,
Pennsylvania19073