Re: SPI: Correct way to rollback a subtransaction? - Mailing list pgsql-hackers

From Marko Kreen
Subject Re: SPI: Correct way to rollback a subtransaction?
Date
Msg-id e51f66da0602210643s279b799iae40f3c34651cd70@mail.gmail.com
Whole thread Raw
In response to Re: SPI: Correct way to rollback a subtransaction?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2/21/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Marko Kreen" <markokr@gmail.com> writes:
> > On 2/20/06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> This seems like a pretty bad idea: if the SPI_connect fails you lose
> >> control without having unwound the subtransaction.  That's unlikely,
> >> but still wrong.
>
> > But if I want the error to reach upper transaction?  SPI_connect
> > failure does not seem a 'expected' situation to me.
>
> In that case you should put the SPI_connect and later SPI_finish
> *outside* the subtransaction and TRY block.  And you'll need
> SPI_restore_connection I think.  This structure would be exactly
> parallel to the way pl_exec.c does it.

It does not seem worth the complexity, I rather go with the simple
approach and put it inside TRY block then.

--
marko


pgsql-hackers by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: pg_config, pg_service.conf, postgresql.conf ....
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] [PATCH] ipv6 support for getaddrinfo.c