Re: Am I in the same transaction block in complex PLPGSQL?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Durumdara <durumdara(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Am I in the same transaction block in complex PLPGSQL?
Date: 2022-03-12 05:23:36
Message-ID: CAKFQuwZG1=_m9f=KXT+sgdGJTWURi_-98h_Fu6KVcJz-cM8dmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Mar 11, 2022 at 9:24 AM Durumdara <durumdara(at)gmail(dot)com> wrote:

> Do you have any idea? Or we must upgrade to min. PGSQL 11 for access
> transaction handling and could post the logs through another transaction?
>

You really do need to open a second session somehow if you want the first
session to be able to fail while still allowing for stuff happening during
its execution to commit.

You can either do this in client-side code by simply opening up two
connections and doing the main work on one while doing the logging on the
other.

As far as I know to do this in-database you would need to use the dblink
extension:

https://www.postgresql.org/docs/current/dblink.html

While much of that module's purpose was subsumed by the addition of FOREIGN
DATA WRAPPERS the ability to have a transaction independent connection back
into the database was not one of those things - using FDW the remote work
is done in the same transaction context as the local database.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Olarte 2022-03-13 08:41:09 Re: COPY TO STDOUT WITH (FORMAT CSV, HEADER), and embedded newlines
Previous Message Michael Lewis 2022-03-12 03:03:09 Re: foreign key on delete cascade order?