On 15.07.21 17:46, Fabien COELHO wrote:
The patch does not apply on Head anymore, could you rebase and post a
patch. I'm changing the status to "Waiting for Author".
Ok. I noticed. The patch got significantly broken by the watch pager
commit. I also have to enhance the added tests (per Peter request).
I wrote a test to check psql query cancel support. I checked that it
fails against the patch that was reverted. Maybe this is useful.
From 6ff6f8b0246cea08b7e329a3e5f49cec3f83a5bc Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Wed, 21 Jul 2021 21:46:11 +0200
Subject: [PATCH] psql: Add test for query canceling
---
src/bin/psql/t/020_cancel.pl | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 src/bin/psql/t/020_cancel.pl
diff --git a/src/bin/psql/t/020_cancel.pl b/src/bin/psql/t/020_cancel.pl
new file mode 100644
index 0000000000..0d56b47ff3
--- /dev/null
+++ b/src/bin/psql/t/020_cancel.pl
@@ -0,0 +1,32 @@
+use strict;
+use warnings;
+
+use PostgresNode;
+use TestLib;
+use Test::More tests => 2;
+
+my $tempdir = TestLib::tempdir;
+
+my $node = get_new_node('main');
+$node->init;
+$node->start;
+
+# test query canceling by sending SIGINT to a running psql
+SKIP: {
+ skip "cancel test requires a Unix shell", 2 if $windows_os;
+
+ local %ENV = $node->_get_env();
+
+ local $SIG{ALRM} = sub {
+ my $psql_pid = TestLib::slurp_file("$tempdir/psql.pid");
+ kill 'INT', $psql_pid;
+ };
+ alarm 1;
+
+ my $stdin = "\\! echo \$PPID >$tempdir/psql.pid\nselect pg_sleep(5);";
+ my ($stdout, $stderr);
+ my $result = IPC::Run::run(['psql', '-v', 'ON_ERROR_STOP=1'], '<',
\$stdin, '>', \$stdout, '2>', \$stderr);
+
+ ok(!$result, 'query failed');
+ like($stderr, qr/canceling statement due to user request/, 'query was
canceled');
+}
--
2.32.0