aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/src/sgml/ref/psql-ref.sgml6
-rw-r--r--src/bin/psql/startup.c4
2 files changed, 7 insertions, 3 deletions
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 1802330b703..fc0e3e4d8ae 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -591,8 +591,10 @@ EOF
<application>psql</application> to issue a <command>BEGIN</command> command
before the first such option and a <command>COMMIT</command> command after
the last one, thereby wrapping all the commands into a single
- transaction. This ensures that either all the commands complete
- successfully, or no changes are applied.
+ transaction. If any of the commands fails, a
+ <command>ROLLBACK</command> command is sent instead. This ensures that
+ either all the commands complete successfully, or no changes are
+ applied.
</para>
<para>
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 392b96eb862..ce180e1cd7b 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -412,7 +412,9 @@ main(int argc, char *argv[])
if (options.single_txn)
{
- if ((res = PSQLexec("COMMIT")) == NULL)
+ res = PSQLexec((successResult == EXIT_SUCCESS) ?
+ "COMMIT" : "ROLLBACK");
+ if (res == NULL)
{
if (pset.on_error_stop)
{