From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andre Holzner <Andre(dot)Holzner(at)cern(dot)ch> |
Cc: | pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org |
Subject: | Array slice subscripts (was Re: [SQL] plpgsql function with more than one array argument) |
Date: | 2002-02-01 21:56:42 |
Message-ID: | 13301.1012600602@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-02-01 22:36:53 | Re: The " \! " and " \l " commands |
Previous Message | Oliver Elphick | 2002-02-01 21:54:07 | Re: The " \! " and " \l " commands |
From | Date | Subject | |
---|---|---|---|
Next Message | Paulo J. Matos | 2002-02-02 01:26:57 | Fractional Results |
Previous Message | Tom Lane | 2002-02-01 21:19:55 | Re: NOTICE: Vacuum: can not process indices, views and certain system tables |