Received: from smtp3.cern.ch (smtp3.cern.ch [137.138.131.164]) by postgresql.org (Postfix) with ESMTP id D33ED4759DF for ; Fri, 22 Feb 2002 04:17:26 -0500 (EST) Received: from cern.ch (rsl3eth11.cern.ch [192.16.165.248]) by smtp3.cern.ch (8.12.1/8.12.1) with ESMTP id g1M9HCf6024132; Fri, 22 Feb 2002 10:17:12 +0100 (MET) X-Authentication-Warning: smtp3.cern.ch: Host rsl3eth11.cern.ch [192.16.165.248] claimed to be cern.ch Message-ID: <3C760C98.3B8ECF48@cern.ch> Date: Fri, 22 Feb 2002 10:17:12 +0100 From: Andre Holzner Organization: ETH Zuerich X-Sender: "Andre Holzner" <@smtp.cern.ch> X-Mailer: Mozilla 4.77C-CERN UNIX lxplus006 45 [en] (X11; U; Linux 2.2.19 i686) X-Accept-Language: en, fr-FR MIME-Version: 1.0 To: Tom Lane Cc: Bruce Momjian , pgsql-hackers@postgresql.org Subject: Re: Array slice subscripts (was Re: [SQL] plpgsql function References: <200202220355.g1M3ttr13214@candle.pha.pa.us> <13842.1014351276@sss.pgh.pa.us> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Archive-Number: 200202/866 X-Sequence-Number: 19148 Hello developpers, Tom Lane wrote: >=20 > Bruce Momjian writes: > > Is this a TODO item? >=20 > I guess so, since no one seems to have objected to the proposed change. > It's a pretty trivial change; I'll take care of it. >=20 > regards, tom lane I learned to live without it, but I wont be the last one=20 who tries to use such queries. best regards & thanks a lot for your efforts, Andr=E9 >=20 > > Tom Lane wrote: > >> Andre Holzner writes: > > Am I doing something wrong or is this a 'feature' ? > >> > >> What's biting you is that the array slice operator uses the provided > >> lower bounds in the resultant array. For example: > >> > >> regression=3D# select pcha from zdec_bhab; > >> pcha > >> ------------------------------------ > >> {{11,12,13},{21,22,23},{31,32,33}} > >> (1 row) > >> > >> regression=3D# select array_dims(pcha) from zdec_bhab; > >> array_dims > >> ------------ > >> [1:3][1:3] > >> (1 row) > >> > >> regression=3D# select pcha[2:2][1:3] from zdec_bhab; > >> pcha > >> -------------- > >> {{21,22,23}} > >> (1 row) > >> > >> regression=3D# select array_dims(pcha[2:2][1:3]) from zdec_bhab; > >> array_dims > >> ------------ > >> [2:2][1:3] > >> (1 row) > >> > >> So your function receives an array with first index starting at 2, > >> which it's not expecting; its attempt to fetch element [1][1] is out > >> of bounds and produces a NULL. > >> > >> Offhand this behavior seems like a misfeature: perhaps it'd be more > >> sensible for the extracted slice to always have index lower bounds > >> set to 1. But I'd like to see some discussion before changing it > >> (and I don't plan to touch it before 7.2 release, in any case ;-)). > >> > >> Comments anyone? > >> > >> regards, tom lane --=20 ------------------+---------------------------------- Andre Holzner | +41 22 76 76750=20 Bureau 32 2-C13 | Building 32=20=20=20=20=20 CERN | Office 2-C13=20=20=20=20 CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/