Re: plpgsql array initialization, what's the story?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: plpgsql array initialization, what's the story?
Date: 2005-03-31 19:59:02
Message-ID: 20050331195902.GA50491@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Audette 2005-03-31 20:07:40 Re: DNN Postgres Data Provider
Previous Message Dann Corbit 2005-03-31 19:20:25 Re: Database monitor (again)