Skip to content

Commit 8cd7627

Browse files
committed
psql: Add test for psql behavior on server crash
Author: Fabien COELHO <coelho@cri.ensmp.fr> Discussion: https://www.postgresql.org/message-id/flat/alpine.DEB.2.21.1904132231510.8961@lancre
1 parent c14a9ee commit 8cd7627

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/bin/psql/t/001_basic.pl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,21 @@ sub psql_fails_like
115115
qr/^Asynchronous notification "foo" with payload "bar" received from server process with PID \d+\.$/,
116116
'notification with payload');
117117

118+
# test behavior and output on server crash
119+
my ($ret, $out, $err) = $node->psql(
120+
'postgres',
121+
"SELECT 'before' AS running;\n" .
122+
"SELECT pg_terminate_backend(pg_backend_pid());\n" .
123+
"SELECT 'AFTER' AS not_running;\n");
124+
125+
is($ret, 2, 'server crash: psql exit code');
126+
like($out, qr/before/, 'server crash: output before crash');
127+
ok($out !~ qr/AFTER/, 'server crash: no output after crash');
128+
is($err, 'psql:<stdin>:2: FATAL: terminating connection due to administrator command
129+
server closed the connection unexpectedly
130+
This probably means the server terminated abnormally
131+
before or while processing the request.
132+
psql:<stdin>:2: fatal: connection to server was lost',
133+
'server crash: error message');
134+
118135
done_testing();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy