From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
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 14:53:15 |
Message-ID: | Y34z2wF4c+lJm3ZT@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Nov 23, 2022 at 02:17:19AM -0600, Justin Pryzby wrote:
> 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
Good point, new text:
The application can now only choose one of these two commands,
since all other commands will be ignored:
Updated patch attached.
--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com
Indecision is a decision. Inaction is an action. Mark Batterson
Attachment | Content-Type | Size |
---|---|---|
xact.diff | text/x-diff | 24.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-11-23 15:07:49 | Re: drop postmaster symlink |
Previous Message | Devrim Gündüz | 2022-11-23 14:28:32 | Re: drop postmaster symlink |