Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3e486c9

Browse files
michaelpqpull[bot]
authored andcommitted
Switch psql's TAP test for query cancellation to use IPC::Run::signal()
Previously, the test relied on a trick with a shell to retrieve the PIDof the psql session to be stopped with SIGINT, that was skipped onWindows. This commit changes the test to use IPC::Run::signal()instead, which still does not work on Windows, but for a differentreason: SIGINT would stop the test before finishing.This should allow the test to run on non-Windows platforms where PPID isnot supported (like NetBSD), spreading it a bit more across thebuildfarm. And the logic of the test is simpler.It is the first time in the tree that IPC::Run::signal() is used, so, asa matter of safety (or just call that as me having cold feet), nobackpatch is done, at least for now.Author: Yugo NAGATAReviewed-by: Fabien CoelhoDiscussion:https://postgr.es/m/20230810125935.22c2922ea5250ba79358965b@sraoss.co.jp
1 parent0204e17 commit3e486c9

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

‎src/bin/psql/t/020_cancel.pl

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,21 @@
1010
use Time::HiResqw(usleep);
1111

1212
# Test query canceling by sending SIGINT to a running psql
13-
#
14-
# There is, as of this writing, no documented way to get the PID of
15-
# the process from IPC::Run. As a workaround, we have psql print its
16-
# own PID (which is the parent of the shell launched by psql) to a
17-
# file.
1813
if ($windows_os)
1914
{
20-
planskip_all=>"cancel test requires a Unix shell";
15+
planskip_all=>'sending SIGINT on Windows terminates the test itself';
2116
}
2217

23-
my$tempdir = PostgreSQL::Test::Utils::tempdir;
24-
2518
my$node = PostgreSQL::Test::Cluster->new('main');
2619
$node->init;
2720
$node->start;
2821

2922
local%ENV =$node->_get_env();
3023

3124
my ($stdin,$stdout,$stderr);
32-
33-
# Test whether shell supports $PPID. It's part of POSIX, but some
34-
# pre-/non-POSIX shells don't support it (e.g., NetBSD).
35-
$stdin ="\\! echo\$PPID";
36-
IPC::Run::run(['psql','-X','-v','ON_ERROR_STOP=1' ],
37-
'<', \$stdin,'>', \$stdout,'2>', \$stderr);
38-
$stdout =~/^\d+$/or skip"shell apparently does not support\$PPID", 2;
39-
40-
# Now start the real test
4125
my$h = IPC::Run::start(['psql','-X','-v','ON_ERROR_STOP=1' ],
4226
\$stdin, \$stdout, \$stderr);
4327

44-
# Get the PID
45-
$stdout ='';
46-
$stderr ='';
47-
$stdin ="\\! echo\$PPID >$tempdir/psql.pid\n";
48-
pump$hwhilelength$stdin;
49-
my$count;
50-
my$psql_pid;
51-
until (
52-
-s"$tempdir/psql.pid"
53-
and
54-
($psql_pid = PostgreSQL::Test::Utils::slurp_file("$tempdir/psql.pid"))
55-
=~/^\d+\n/s)
56-
{
57-
($count++ < 100 *$PostgreSQL::Test::Utils::timeout_default)
58-
ordie"pid file did not appear";
59-
usleep(10_000);
60-
}
61-
6228
# Send sleep command and wait until the server has registered it
6329
$stdin ="select pg_sleep($PostgreSQL::Test::Utils::timeout_default);\n";
6430
pump$hwhilelength$stdin;
@@ -67,7 +33,7 @@
6733
)ordie"timed out";
6834

6935
# Send cancel request
70-
kill'INT',$psql_pid;
36+
$h->signal('INT');
7137

7238
my$result = finish$h;
7339

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp