postgresql/src
Michael Paquier a04ccf6dfb Fix psql's single transaction mode on client-side errors with -c/-f switches
psql --single-transaction is able to handle multiple -c and -f switches
in a single transaction since d5563d7d, but this had the surprising
behavior of forcing a transaction COMMIT even if psql failed with an
error in the client (for example incorrect path given to \copy), which
would generate an error, but still commit any changes that were already
applied in the backend.  This commit makes the behavior more consistent,
by enforcing a transaction ROLLBACK if any commands fail, both
client-side and backend-side, so as no changes are applied if one error
happens in any of them.

Some tests are added on HEAD to provide some coverage about all that.
Backend-side errors are unreliable as IPC::Run can complain on SIGPIPE
if psql quits before reading a query result, but that should work
properly in the case where any errors come from psql itself, which is
what the original report is about.

Reported-by: Christoph Berg
Author: Kyotaro Horiguchi, Michael Paquier
Discussion: https://postgr.es/m/17504-76b68018e130415e@postgresql.org
Backpatch-through: 10
2022-06-06 11:07:22 +09:00
..
backend Silence compiler warnings from some older compilers. 2022-06-01 17:21:45 -04:00
bin Fix psql's single transaction mode on client-side errors with -c/-f switches 2022-06-06 11:07:22 +09:00
common Inhibit mingw CRT's auto-globbing of command line arguments 2022-04-25 15:49:35 -04:00
fe_utils Allow db.schema.table patterns, but complain about random garbage. 2022-04-20 11:39:44 -04:00
include Repurpose PROC_COPYABLE_FLAGS as PROC_XMIN_FLAGS 2022-05-19 16:20:32 +02:00
interfaces Remove misguided SSL key file ownership check in libpq. 2022-05-26 14:14:05 -04:00
makefiles Add NO_INSTALL option to pgxs 2021-05-27 13:58:29 +02:00
pl Fix pl/perl test case so it will still work under Perl 5.36. 2022-06-01 16:15:47 -04:00
port Fix compatibility thinko for fstat() on standard streams in win32stat.c 2021-11-30 09:55:56 +09:00
template Further tweaking of PG_SYSROOT heuristics for macOS. 2021-01-20 12:07:23 -05:00
test Show 'AS "?column?"' explicitly when it's important. 2022-05-21 14:45:58 -04:00
timezone Update time zone data files to tzdata release 2022a. 2022-05-05 14:55:03 -04:00
tools Improve setup of environment values for commands in MSVC's vcregress.pl 2022-05-11 10:22:29 +09:00
tutorial doc: Prefer explicit JOIN syntax over old implicit syntax in tutorial 2021-04-08 10:51:26 +02:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Add module build directory to the PATH for TAP tests 2021-10-22 09:50:16 -04:00
Makefile.shlib AIX: Fix missing libpq symbols by respecting SHLIB_EXPORTS. 2021-09-06 11:28:02 -07:00
nls-global.mk Add errhint_plural() function and make use of it 2021-03-31 09:16:25 +02:00