"Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
>> ERROR: query didn't return correct # of attributes for *internal*
> AFAIC,"SELECT FOR UPDATE" always causes above errors in
> PL/pgSQL functions.
> ORDER/GROUP BY items that are not in the targetlist also cause
> same errors in PL/pgSQL functions.
> In both cases,target entries are added which are not wanted in the
> final projected tuple(SELECT FOR UPDATE adds "ctid" entry).
It sounds like the code that deals with the resulting tuple is not
smart enough to ignore resjunk attributes (or to call ExecProject
if it needs an actual junk-free tuple). That's probably an easily
fixed bug, but I'm not familiar with the PL code...
regards, tom lane