X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 78C5252886 for ; Fri, 24 Jun 2005 22:50:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80143-07 for ; Sat, 25 Jun 2005 01:50:28 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id 0F1705280C for ; Fri, 24 Jun 2005 22:50:27 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j5P1oNO01032; Fri, 24 Jun 2005 21:50:23 -0400 (EDT) From: Bruce Momjian Message-Id: <200506250150.j5P1oNO01032@candle.pha.pa.us> Subject: Re: [SQL] ARRAY() returning NULL instead of ARRAY[] In-Reply-To: <1118074367.5506.16.camel@dicaprio.akademie1.de> To: "Markus Bertheau ?" Date: Fri, 24 Jun 2005 21:50:23 -0400 (EDT) Cc: Joe Conway , pgsql-hackers@postgresql.org, Tom Lane X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/1176 X-Sequence-Number: 69657 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 ? > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > -- 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, Pennsylvania 19073