From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: p.pierotti@mmbb.it
To: pgsql-general@postgresql.org
Subject: Re: Problem with stored procedure and nested transactions
Date: Sat, 3 Nov 2018 09:48:09 +0100
Message-ID: <9b2b5575-7e28-832e-3559-7bfce974c525@2ndquadrant.com> (raw)
In-Reply-To: <008501d47059$48073860$d815a920$@mmbb.it>
References: <008501d47059$48073860$d815a920$@mmbb.it>
On 30/10/2018 15:03, p.pierotti@mmbb.it wrote:
> I thought that the “BEGIN/END” block was used to create new transactions
> and that each of them could be managed individually.
In PL/pgSQL, BEGIN/END just create syntactic blocks, they don't manage
transactions.
COMMIT and ROLLBACK manage top-level transactions, but those cannot be
nested (since they are top-level).
In order to create a nested transaction structure, you need to use
subtransactions. In PL/pgSQL, you can use BEGIN/END blocks with an
exception clause to create subtransactions.
I'm not sure what your code is actually trying to do, but you might need
to reorganize it a bit.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com, p.pierotti@mmbb.it
Subject: Re: Problem with stored procedure and nested transactions
In-Reply-To: <9b2b5575-7e28-832e-3559-7bfce974c525@2ndquadrant.com>
References: <008501d47059$48073860$d815a920$@mmbb.it> <9b2b5575-7e28-832e-3559-7bfce974c525@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox