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