Re: plpgsql array initialization, what's the story? - Mailing list pgsql-general

From Michael Fuhr
Subject Re: plpgsql array initialization, what's the story?
Date
Msg-id 20050331195902.GA50491@winnie.fuhr.org
Whole thread Raw
In response to plpgsql array initialization, what's the story?  ("Karl O. Pinc" <kop@meme.com>)
Responses Re: plpgsql array initialization, what's the story?
List pgsql-general
On Thu, Mar 31, 2005 at 07:13:30PM +0000, Karl O. Pinc wrote:
> Postgresql 8.0.1
>
> If I write the plpgsql:
>
> declare
> y int[];
> begin
> y[1] := 1;
> y[2] := 2;
> y[3] := 3;
> ...
>
> All y[] array elements are NULL, as is array_dims(y).

I think this has been fixed for 8.0.2:

http://archives.postgresql.org/pgsql-committers/2005-02/msg00012.php

Here's a test in 8.0.2beta1:

CREATE FUNCTION foo() RETURNS integer[] AS $$
DECLARE
    y  integer[];
BEGIN
    y[1] := 1;
    y[2] := 2;
    y[3] := 3;

    RETURN y;
END;
$$ LANGUAGE plpgsql;

SELECT foo();
   foo
---------
 {1,2,3}
(1 row)

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-general by date:

Previous
From: "Dann Corbit"
Date:
Subject: Re: Database monitor (again)
Next
From: Joe Audette
Date:
Subject: Re: DNN Postgres Data Provider