RE: PL/pgSQL bug?

From: "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Tatsuo Ishii" <t-ishii(at)sra(dot)co(dot)jp>
Cc: <JanWieck(at)Yahoo(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: PL/pgSQL bug?
Date: 2001-08-13 08:01:58
Message-ID: EKEJJICOHDIEMGPNIFIJAENPFBAA.Inoue@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tatsuo Ishii wrote:
>
> > > One way to make the results equivalent is to compute a new
QuerySnapshot
> > > for each SPI query. Quite aside from the cost of doing so, I do not
> > > think it makes sense, considering that the previous QuerySnapshot must
> > > be restored when we return from the function. Do we really want
> > > functions to see transaction status different from what's seen outside
> > > the function call?
> >
> > Yes I do.
>
> Me too. Current behavior of procedural languages seem hard to
> understand for users.
>

Yes it's a siginificant point. I've referred to the
impropriety to use a unique snapshot thoughout a
function call when this kind of bug(?) was reported.
Who could take care of it in writing PL/pgSQL ?

> BTW, why must we restore the previous QuerySnapshot?

For example, in the case such as
select .., some_func(item1), .. from a_table;
SELECT always uses the same snapshot for all its
internal fetch operations, so it seems reasonable
for each some_func() to be called in the same snapshot.
It's possible for a function to use a unique snapshot
if there are only SELECT statements in the function
but it's impossible if there are UPDATE/DELETE or
SELECT .. FOR UPDATE statements etc.. We should be
careful to handle such functions which have side
effects. IMHO we shouldn't call such functions or
shouldn't expect consistent results with the use
of such funtions. OTOH
select some_func(..);
is a procedure call not a function call in reality.
There seems to be no necessity to restore the previous
QuerySnapshot when calling procedures and we could
call any function as a procedure.

regards,
Hiroshi Inoue

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gavin Sherry 2001-08-13 08:49:50 Re: example program bug?
Previous Message Ian Lance Taylor 2001-08-13 04:51:55 Re: Re: [PATCHES] Select parser at runtime