Re: PL/pgSQL: EXCEPTION NOSAVEPOINT

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matt Miller <mattm(at)epx(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: PL/pgSQL: EXCEPTION NOSAVEPOINT
Date: 2005-09-01 23:18:25
Message-ID: 8401.1125616705@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches

Matt Miller <mattm(at)epx(dot)com> writes:
> If I were fool enough to plan an attack on the main executor's exception
> handling to try and disarm it of its subtransaction semantics, where
> would I start? Where would I end? What would I do in between? Can New
> Orleans be rebuilt above sea level?

In general I don't think it even makes sense to think of making executor
rollback non-transactional. If the executor was running, say, an INSERT
or UPDATE that had already made some database changes before failing,
you certainly don't want those partial results to be seen as good.

ISTM what you are after is to provide some computational capability in
plpgsql that is restricted from doing any database access, and therefore
isn't subject to the above complaint. I'm not sure about a good way to
do this. Seems like your choices are to re-invent the wheel by
implementing a separate expression evaluator inside plpgsql, or to try
to create a locked-down, limited-capability option in execQual.c.
(The main problem with the latter route is to do it without adding any
overhead for normal execution, as otherwise you'll probably get shot
down on that basis.) In either case it's not immediately obvious how
you tell what is safe to allow --- Postgres' model that everything is
embedded within black-box functions doesn't help you here. The
IMMUTABLE/STABLE/VOLATILE marking of functions is close to what you
want, but not close enough.

Also, it might be possible to make the restriction "read-only database
access" instead of "no database access"; this would certainly fit a lot
better with the existing function volatility categories, but then you
still have the problem that aborting the executor is just not a
low-overhead control path. And you would have to go through just about
all of the existing subxact cleanup, such as releasing locks and buffer
pins acquired within the failing query.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-09-02 00:02:56 Re: Performance question (FOR loop)
Previous Message Matt Miller 2005-09-01 22:58:38 Re: PL/pgSQL: EXCEPTION NOSAVEPOINT

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-09-02 00:47:26 Re: Pre-allocated free space for row
Previous Message Stephan Szabo 2005-09-01 22:59:15 Re: Work-in-progress referential action trigger timing

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-09-02 01:06:18 Re: [BUGS] PSQL commands not backwards-compatible
Previous Message Stephan Szabo 2005-09-01 22:59:15 Re: Work-in-progress referential action trigger timing