Re: SPI: Correct way to rollback a subtransaction?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marko Kreen" <markokr(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SPI: Correct way to rollback a subtransaction?
Date: 2006-02-20 23:20:00
Message-ID: 29559.1140477600@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Marko Kreen" <markokr(at)gmail(dot)com> writes:
> On 2/20/06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sergey E. Koposov 2006-02-21 00:22:01 Re: dropped columns, tupDesc
Previous Message Tom Lane 2006-02-20 22:57:04 Re: dropped columns, tupDesc