From: Daniel Gustafsson Date: Fri, 13 Feb 2026 10:36:31 +0000 (+0100) Subject: Restart BackgroundPsql's timer more nicely. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53c6bd0aa3de58baf828e60c6c8934d0a10a8501;p=thirdparty%2Fpostgresql.git 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 Reviewed-by: Heikki Linnakangas Reviewed-by: Andrew Dunstan Reviewed-by: Tom Lane Discussion: https://postgr.es/m/1100715.1712265845@sss.pgh.pa.us --- 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);