Re: Populating a sparse array piecemeal in plpgsql - Mailing list pgsql-general

From Tom Lane
Subject Re: Populating a sparse array piecemeal in plpgsql
Date
Msg-id 27950.1210833010@sss.pgh.pa.us
Whole thread Raw
In response to Populating a sparse array piecemeal in plpgsql  ("Eliot, Christopher" <christopher.eliot@nagrastar.com>)
Responses Re: Populating a sparse array piecemeal in plpgsql
List pgsql-general
"Eliot, Christopher" <christopher.eliot@nagrastar.com> writes:
> CREATE FUNCTION func1()
> RETURNS VOID AS $$
> DECLARE
>     a INTEGER[2][2][2][200];
> BEGIN
>     a[1][2][1][33] = 0;
>     a[2][1][1][33] = 0;
> END;
> $$ LANGUAGE PLPGSQL;

> When I run this function, I get:
> ERROR:  array subscript out of range.

Yeah.  I'm afraid that declaration is basically just noise: it doesn't
do anything for you that "DECLARE a integer[];" wouldn't do.  If you
want the array actually filled out to the indicated dimensions then
you have to do that by hand.

            regards, tom lane

pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: multicolumn index join
Next
From: "IVO GELOV"
Date:
Subject: Strange behaviour - performance decreases after each TRUNCATE