Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 1ECC1475B6A; Thu, 21 Feb 2002 23:14:40 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g1M4EaS13845; Thu, 21 Feb 2002 23:14:37 -0500 (EST) To: Bruce Momjian Cc: Andre Holzner , pgsql-sql@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: Array slice subscripts (was Re: [SQL] plpgsql function with more than one array argument) In-reply-to: <200202220355.g1M3ttr13214@candle.pha.pa.us> References: <200202220355.g1M3ttr13214@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Thu, 21 Feb 2002 22:55:55 -0500" Date: Thu, 21 Feb 2002 23:14:36 -0500 Message-ID: <13842.1014351276@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200202/834 X-Sequence-Number: 19119 Bruce Momjian writes: > Is this a TODO item? 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. regards, tom lane > 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=# select pcha from zdec_bhab; >> pcha >> ------------------------------------ >> {{11,12,13},{21,22,23},{31,32,33}} >> (1 row) >> >> regression=# select array_dims(pcha) from zdec_bhab; >> array_dims >> ------------ >> [1:3][1:3] >> (1 row) >> >> regression=# select pcha[2:2][1:3] from zdec_bhab; >> pcha >> -------------- >> {{21,22,23}} >> (1 row) >> >> regression=# 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