Re: New docs chapter on Transaction Management and related changes

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Erik Rijkers <er(at)xs4all(dot)nl>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Robert Treat <rob(at)xzilla(dot)net>, Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: New docs chapter on Transaction Management and related changes
Date: 2022-11-23 08:17:19
Message-ID: 20221123081718.GI11463@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 22, 2022 at 01:50:36PM -0500, Bruce Momjian wrote:
> +
> + <para>
> + A more complex example with multiple nested subtransactions:
> +<programlisting>
> +BEGIN;
> + INSERT INTO table1 VALUES (1);
> + SAVEPOINT sp1;
> + INSERT INTO table1 VALUES (2);
> + SAVEPOINT sp2;
> + INSERT INTO table1 VALUES (3);
> + RELEASE SAVEPOINT sp2;
> + INSERT INTO table1 VALUES (4))); -- generates an error
> +</programlisting>
> + In this example, the application requests the release of the savepoint
> + <literal>sp2</literal>, which inserted 3. This changes the insert's
> + transaction context to <literal>sp1</literal>. When the statement
> + attempting to insert value 4 generates an error, the insertion of 2 and
> + 4 are lost because they are in the same, now-rolled back savepoint,
> + and value 3 is in the same transaction context. The application can
> + now only choose one of these two commands, since all other commands
> + will be ignored with a warning:
> +<programlisting>
> + ROLLBACK;
> + ROLLBACK TO SAVEPOINT sp1;
> +</programlisting>
> + Choosing <command>ROLLBACK</command> will abort everything, including
> + value 1, whereas <command>ROLLBACK TO SAVEPOINT sp1</command> will retain
> + value 1 and allow the transaction to continue.
> + </para>

This mentions a warning, but what happens is actually an error:

postgres=!# select;
ERROR: current transaction is aborted, commands ignored until end of transaction block

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message sirisha chamarthi 2022-11-23 08:27:08 Re: Prefetch the next tuple's memory during seqscans
Previous Message Thomas Munro 2022-11-23 08:14:56 Re: More efficient build farm animal wakeup?