Re: Array slice subscripts (was Re: [SQL] plpgsql function

From: Andre Holzner <Andre(dot)Holzner(at)cern(dot)ch>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Array slice subscripts (was Re: [SQL] plpgsql function
Date: 2002-02-22 09:17:12
Message-ID: 3C760C98.3B8ECF48@cern.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

Hello developpers,

Tom Lane wrote:
>
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> 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

I learned to live without it, but I wont be the last one
who tries to use such queries.

best regards & thanks a lot for your efforts,

André

>
> > Tom Lane wrote:
> >> Andre Holzner <Andre(dot)Holzner(at)cern(dot)ch> 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

--
------------------+----------------------------------
Andre Holzner | +41 22 76 76750
Bureau 32 2-C13 | Building 32
CERN | Office 2-C13
CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2002-02-22 09:23:10 Re: [ODBC] UTF-8 data migration problem in Postgresql 7.2
Previous Message Tatsuo Ishii 2002-02-22 09:05:20 Re: [ODBC] UTF-8 data migration problem in Postgresql 7.2

Browse pgsql-sql by date

  From Date Subject
Next Message Graham Vickrage 2002-02-22 13:18:51 quotes nightmare!
Previous Message Christopher Kings-Lynne 2002-02-22 09:02:29 Re: Can someone help me with this function?