Re: Recording exceptions within function (autonomous transactions?)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Scott Mead <scottm(at)openscg(dot)com>
Cc: Steve Pritchard <steve(dot)pritchard(at)bto(dot)org>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Recording exceptions within function (autonomous transactions?)
Date: 2015-10-06 14:14:32
Message-ID: 5990.1444140872@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Scott Mead <scottm(at)openscg(dot)com> writes:
>> On Oct 6, 2015, at 05:38, Steve Pritchard <steve(dot)pritchard(at)bto(dot)org> wrote:
>> [ how to fake an autonomous transaction? ]

> It's hacky, and, I haven't tried it in a few years. Setup a foreign table that resides in the same database. When you write to the foreign table, it will be using a 'loopback' connection, and that transaction will be able to commit because it is a separate connection.
> To be fair, I haven't actually done this since the days of dblink, I *believe* it should work with fdw though.

My recollection is that you can do this with dblink, but *not* with FDWs
--- or at least, not with postgres_fdw. The latter is smart enough to
roll back your remote transaction when the local one rolls back.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Melvin Davidson 2015-10-06 14:15:46 Re: Processing data from table using awk.
Previous Message John McKown 2015-10-06 14:04:35 Processing data from table using awk.