v5-0001-Restart-BackgroundPsql-s-timer-more-nicely.patch
text/x-diff
Filename: v5-0001-Restart-BackgroundPsql-s-timer-more-nicely.patch
Type: text/x-diff
Part: 0
Patch
Format: format-patch
Series: patch v5-0001
Subject: Restart BackgroundPsql's timer more nicely.
| File | + | − |
|---|---|---|
| src/bin/psql/t/010_tab_completion.pl | 3 | 4 |
| src/bin/psql/t/030_pager.pl | 3 | 4 |
From 6abdea6c16617312cc3ecfd12342146924b75b8d Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Wed, 11 Feb 2026 14:55:04 -0500
Subject: [PATCH v5] Restart BackgroundPsql's timer more nicely.
Use BackgroundPsql's published API for automatically restarting
its timer for each query, rather than manually reaching into it
to achieve the same thing.
010_tab_completion.pl's logic for this predates the invention
of BackgroundPsql (and 664d75753 missed the opportunity to
make it cleaner). 030_pager.pl copied-and-pasted the code.
Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/1100715.1712265845@sss.pgh.pa.us
---
src/bin/psql/t/010_tab_completion.pl | 7 +++----
src/bin/psql/t/030_pager.pl | 7 +++----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl
index 7104aba2394..1d2e5f5b92a 100644
--- a/src/bin/psql/t/010_tab_completion.pl
+++ b/src/bin/psql/t/010_tab_completion.pl
@@ -77,8 +77,10 @@ close $FH;
# for possible debugging purposes.
my $historyfile = "${PostgreSQL::Test::Utils::log_path}/010_psql_history.txt";
-# fire up an interactive psql session
+# fire up an interactive psql session and configure it such that each query
+# restarts the timer
my $h = $node->interactive_psql('postgres', history_file => $historyfile);
+$h->set_query_timer_restart();
# Simple test case: type something and see if psql responds as expected
sub check_completion
@@ -88,9 +90,6 @@ sub check_completion
# report test failures from caller location
local $Test::Builder::Level = $Test::Builder::Level + 1;
- # restart per-command timer
- $h->{timeout}->start($PostgreSQL::Test::Utils::timeout_default);
-
# send the data to be sent and wait for its result
my $out = $h->query_until($pattern, $send);
my $okay = ($out =~ $pattern && !$h->{timeout}->is_expired);
diff --git a/src/bin/psql/t/030_pager.pl b/src/bin/psql/t/030_pager.pl
index a35f2b26293..d3f964639d3 100644
--- a/src/bin/psql/t/030_pager.pl
+++ b/src/bin/psql/t/030_pager.pl
@@ -70,8 +70,10 @@ $node->safe_psql(
25 as y,
26 as z');
-# fire up an interactive psql session
+# fire up an interactive psql session and configure it such that each query
+# restarts the timer
my $h = $node->interactive_psql('postgres');
+$h->set_query_timer_restart();
# set the pty's window size to known values
# (requires undesirable chumminess with the innards of IPC::Run)
@@ -88,9 +90,6 @@ sub do_command
# report test failures from caller location
local $Test::Builder::Level = $Test::Builder::Level + 1;
- # restart per-command timer
- $h->{timeout}->start($PostgreSQL::Test::Utils::timeout_default);
-
# send the data to be sent and wait for its result
my $out = $h->query_until($pattern, $send);
my $okay = ($out =~ $pattern && !$h->{timeout}->is_expired);
--
2.43.7