RE: [HACKERS] SELECT FOR UPDATE in (PL/pgSQL) function - Mailing list pgsql-hackers

From Hiroshi Inoue
Subject RE: [HACKERS] SELECT FOR UPDATE in (PL/pgSQL) function
Date
Msg-id 000101bed8a5$196b04c0$2801007e@cadzone.tpf.co.jp
Whole thread Raw
In response to SELECT FOR UPDATE in function  (Oleg Bartunov <oleg@sai.msu.su>)
Responses Re: [HACKERS] SELECT FOR UPDATE in (PL/pgSQL) function
List pgsql-hackers
>
> Is't possible to use SELECT FOR UPDATE in functions ?
> I have function for 'insert or update' which works ok, but as I have some
> problem with duplicated records I tried as suggested by Tom Lane to use
> SELECT FOR UPDATE instead of just select. Unfortunately it doesn't works:
>
> ERROR:  query didn't return correct # of attributes for *internal*
>

AFAIC,"SELECT FOR UPDATE" always causes above errors in
PL/pgSQL functions.
Could we use PL/pgSQL for update procedures in MVCC ?

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).

In such cases,the # of target entries is different from the # of
final attributes estimated in pl_gram.y and above elog() in
pl_exec.c is called.

Should current check be loosen ?
Or another check is necessary ?

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp




pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Bug tracking system policy
Next
From: "Ross J. Reedstrom"
Date:
Subject: Re: [HACKERS] Checking if a system is ELF