mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Transaction chaining
Add command variants COMMIT AND CHAIN and ROLLBACK AND CHAIN, which start new transactions with the same transaction characteristics as the just finished one, per SQL standard. Support for transaction chaining in PL/pgSQL is also added. This functionality is especially useful when running COMMIT in a loop in PL/pgSQL. Reviewed-by: Fabien COELHO <coelho@cri.ensmp.fr> Discussion: https://www.postgresql.org/message-id/flat/28536681-324b-10dc-ade8-ab46f7645a5a@2ndquadrant.com
This commit is contained in:
@@ -21,7 +21,7 @@ PostgreSQL documentation
|
||||
|
||||
<refsynopsisdiv>
|
||||
<synopsis>
|
||||
COMMIT [ WORK | TRANSACTION ]
|
||||
COMMIT [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]
|
||||
</synopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
@@ -38,6 +38,10 @@ COMMIT [ WORK | TRANSACTION ]
|
||||
<refsect1>
|
||||
<title>Parameters</title>
|
||||
|
||||
<indexterm zone="sql-commit-chain">
|
||||
<primary>chained transactions</primary>
|
||||
</indexterm>
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><literal>WORK</literal></term>
|
||||
@@ -48,6 +52,18 @@ COMMIT [ WORK | TRANSACTION ]
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="sql-commit-chain">
|
||||
<term><literal>AND CHAIN</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If <literal>AND CHAIN</literal> is specified, a new transaction is
|
||||
immediately started with the same transaction characteristics (see <xref
|
||||
linkend="sql-set-transaction"/>) as the just finished one. Otherwise,
|
||||
no new transaction is started.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
@@ -79,9 +95,8 @@ COMMIT;
|
||||
<title>Compatibility</title>
|
||||
|
||||
<para>
|
||||
The SQL standard only specifies the two forms
|
||||
<literal>COMMIT</literal> and <literal>COMMIT
|
||||
WORK</literal>. Otherwise, this command is fully conforming.
|
||||
The command <command>COMMIT</command> conforms to the SQL standard. The
|
||||
form <literal>COMMIT TRANSACTION</literal> is a PostgreSQL extension.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
Reference in New Issue
Block a user