From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Markus Bertheau <twanger(at)bluetwanger(dot)de>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: ARRAY() returning NULL instead of ARRAY[] resp. {} |
Date: | 2005-06-04 17:52:16 |
Message-ID: | 200506041752.j54HqGZ12891@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches pgsql-sql |
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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2005-06-04 18:14:30 | Re: [HACKERS] Fix PID file location? |
Previous Message | Bruce Momjian | 2005-06-04 16:52:55 | Re: O_DIRECT for WAL writes |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2005-06-04 18:14:30 | Re: [HACKERS] Fix PID file location? |
Previous Message | Bruce Momjian | 2005-06-04 16:52:55 | Re: O_DIRECT for WAL writes |
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2005-06-04 21:01:18 | Re: ARRAY() returning NULL instead of ARRAY[] resp. {} |
Previous Message | Federico Pedemonte | 2005-06-04 16:19:35 | Re: Multiple SRF parameters from query |