Re: SQL-Invoked Procedures for 8.1

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SQL-Invoked Procedures for 8.1
Date: 2004-10-02 19:17:43
Message-ID: 20041002191743.GA5738@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 24, 2004 at 07:28:09PM +1000, Neil Conway wrote:
> On Fri, 2004-09-24 at 05:52, Alvaro Herrera wrote:
> > I don't think we can do that in a standard function, at least not
> > without a lot of work.
>
> Can you elaborate on why this would be so difficult?

Because you have to keep the function state somewhere. Currently, all
functions are handled in the SPI stack, which is dependent on the
transaction machinery. So you'd have to move the function state
somewhere else -- maybe keeping a special SPI stack outside transaction
management. Or maybe the procedure handler does not use SPI at all.

In any case, you need some way to handle cleaning it up if the procedure
happens to fail; it needs to be able to cope with failing transactions
that have to be handled (because some operations in the procedure can be
handled), and some others that have to abort the procedure as a whole.
This sounds like a meta-transaction (transaction of transactions).
Apparently you also need some way to use "savepoints," but since you are
not in a normal transaction you can't use the current mechanism for
those. (Not sure if you really need cross-transaction "savepoints").

_And_ you need to handle all this from the procedure handler. The
current SPI exposes a limited subset of transaction handling to function
handlers; you'd need to extend that (unless you are planning to have
non-pluggable procedure handlers).

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Tiene valor aquel que admite que es un cobarde" (Fernandel)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2004-10-02 19:54:43 Re: Mislabeled timestamp functions (was Re: [SQL] [NOVICE] date_trunc'd timestamp index possible?)
Previous Message Josh Berkus 2004-10-02 18:36:08 Re: SQL-Invoked Procedures for 8.1