Re: proposal: plpgsql - iteration over fields of rec or row variable - Mailing list pgsql-hackers

From Tom Lane
Subject Re: proposal: plpgsql - iteration over fields of rec or row variable
Date
Msg-id 27600.1289242331@sss.pgh.pa.us
Whole thread Raw
In response to proposal: plpgsql - iteration over fields of rec or row variable  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: proposal: plpgsql - iteration over fields of rec or row variable
List pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> FOR varname OVER [row | rec variable]
> LOOP
>    {{body}}
> END LOOP

> this syntax isn't final. The real type of control variable is
> specified in runtime and can be changed between iterations.

If you don't know the type or even the name of the field that varname
currently represents, how is the loop body going to do anything useful?

> This variable should be
> writeable - so we are able to change any field of record.

And that is just plain horrid.  The loop variable is a separate
variable, not a modifiable alias for a field, in every existing form
of plpgsql loop.

The idea of multiple instances of the loop body code seems like a mess
anyway.  I think this is basically hacking plpgsql beyond recognition
to solve problems that are better solved in plperl or pltcl.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: How to share the result data of separated plan
Next
From: Bernd Helmle
Date:
Subject: Re: How can we tell how far behind the standby is?