Re: [SQL] ARRAY() returning NULL instead of ARRAY[]

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Markus Bertheau ?" <twanger(at)bluetwanger(dot)de>
Cc: Joe Conway <mail(at)joeconway(dot)com>, pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [SQL] ARRAY() returning NULL instead of ARRAY[]
Date: 2005-06-25 01:50:23
Message-ID: 200506250150.j5P1oNO01032@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches pgsql-sql


Is this a TODO item?

---------------------------------------------------------------------------

Markus Bertheau ? wrote:
> ? ???, 06/06/2005 ? 08:58 -0700, Joe Conway ?????:
> > Joe Conway wrote:
> > > Actually, consistent with my last post, I think array_upper() on a
> > > zero-element array should return NULL. A zero-element array has a
> > > defined lower bound, but its upper bound is not zero -- it is really
> > > undefined.
> >
> > Just to clarify my response, this is what I propose:
> >
> > regression=# select array_upper('[2][1:]={{},{}}'::int[],1);
> > array_upper
> > -------------
> > 2
> > (1 row)
> >
> > regression=# select array_upper('[2][1:]={{},{}}'::int[],2) IS NULL;
> > ?column?
> > ----------
> > t
> > (1 row)
>
> Hmm, this gets really complicated and inconsistent. Complicated means
> unusable. What about modifying the dimension syntax such that the second
> number means number of elements instead of upper bound? That particular
> problem would go away then, and array_upper('[0:0]={}'::int[]) can
> return the correct 0 then.
>
> What I'm actually worrying about is that array_upper(array(select 1
> where false)) returns 0.
>
> An option would be to drop the possibility to let the array start at
> another index than 0. I don't know why it was decided to do that in the
> first place. It seems a rather odd feature to me.
>
> Markus
> --
> Markus Bertheau ? <twanger(at)bluetwanger(dot)de>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

--
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-06-25 02:14:09 Re: [COMMITTERS] pgsql: Fix NUMERIC modulus to properly
Previous Message Bruce Momjian 2005-06-25 01:32:29 Re: [COMMITTERS] pgsql: Fix NUMERIC modulus to properly truncate

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-06-25 02:24:31 Re: Add PG version number to NLS files
Previous Message Bruce Momjian 2005-06-25 00:03:08 Re: hash index work

Browse pgsql-sql by date

  From Date Subject
Next Message Greg Sabino Mullane 2005-06-25 03:35:40 Re: people who buy A, also buy C, D, E
Previous Message Dmitri Bichko 2005-06-24 23:01:56 Default index space?