Re: final patch - plpgsql: for-in-array

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Valentine Gogichashvili <valgog@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Pavel Stehule <pavel.stehule@gmail.com>, Andrew Dunstan <andrew@dunslane.net>, Merlin Moncure <mmoncure@gmail.com>, Jaime Casanova <jaime@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>
Date: 2010-11-22T14:29:43Z
Lists: pgsql-hackers
On Mon, Nov 22, 2010 at 6:21 AM, Valentine Gogichashvili
<valgog@gmail.com> wrote:
> Hi,
> with the FOR e IN SELECT UNNEST(a) construct there is an issue again related
> to the unresting of composite type arrays:
> [ example ]
> Is it a bug or a feature?

It looks like the problem in this example is that PL/pgsql tries to
assign the result of unest(ta) to t.i rather than to t as a whole.
This is pretty ridiculously stupid in this case, but it would make
sense if the subselect where of the form SELECT a, b, c FROM ...

I haven't looked at the code to see whether there's a way to make this
case smarter (it would be nice - I've been bitten by similar problems
myself) but it's only tangentially related to the patch under
discussion.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company