Re: Error handling in plperl and pltcl

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: Thomas Hallgren <thhal(at)mailblocks(dot)com>
Cc: Richard Huxton <dev(at)archonet(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, James William Pye <flaw(at)rhid(dot)com>, Jan Wieck <JanWieck(at)Yahoo(dot)com>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Error handling in plperl and pltcl
Date: 2004-12-01 16:05:15
Message-ID: 200412011105.15048.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday 01 December 2004 04:12, Thomas Hallgren wrote:
> Richard Huxton wrote:
> > Can I make some counter-proposals?
> >
> > 1. Wrap each function body/call (same thing here afaict) in a
> > sub-transaction. An exception can be caught within that function, and
> > all the spi in that function is then rolled back. This is rubbish, but
> > at least it's predictable and allows you to write to a log table and
> > throw another exception.
>
> This will be even worse since it will impose the subtransaction overhead
> on everything, even functions that never do any database access. Perhaps
> this approach would be feasible if imposed on volatile functions only,
> but then again, the volatility of a function cannot be trusted since we
> have no way of defining a "stable but with side effects" type.
>

Agreed.

> > 2. For pl/tcl introduce a pgtry { } catch { } which just starts a
> > sub-transaction and does standard try/catch. I don't use TCL, but from
> > the little I know this should be straightforward.
>
> If you know how to use special constructs like this, what's wrong with
> actually using savepoints verbatim? I.e.
>
> INSERT 1
> INSERT 2
> SAVEPOINT foo
> try {
> INSERT 3
> INSERT 4
> RELEASE foo
> }
> catch WHATEVER {
> ROLLBACK TO foo
> INSERT 5
> INSERT 6
> }
>
> IMHO a very clean, sensible, and easily understood approach that doesn't
> clobber the language.
>

Agreed. The fewer special constructs the better imho.

--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2004-12-01 16:17:52 Re: Increasing the length of
Previous Message Bruce Momjian 2004-12-01 15:41:59 Re: libpq and psql not on same page about SIGPIPE