plpgsql array initialization, what's the story?

From: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: plpgsql array initialization, what's the story?
Date: 2005-03-31 19:13:30
Message-ID: 1112296410l.15411l.0l@mofo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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).
But if I write:

declare
y int[] := '{}';
begin
y[1] := 1;
y[2] := 2;
y[3] := 3;
...

Then things work as expected.

What's going on? (As in "Gosh, it looks like something's
happening here that I should know about.")

This behavior is not clear from the plpgsql documentation.

Regards,

Karl <kop(at)meme(dot)com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

Responses

Browse pgsql-general by date

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