]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Restart BackgroundPsql's timer more nicely.
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 13 Feb 2026 10:36:31 +0000 (11:36 +0100)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Fri, 13 Feb 2026 10:36:31 +0000 (11:36 +0100)
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
src/bin/psql/t/030_pager.pl

index 7104aba239430a69f322f065c3e3fd997b0a0339..1d2e5f5b92a7c687547d39d9f4553ef5352cb1c7 100644 (file)
@@ -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);
index a35f2b2629359a9b10e0482555b9e5cdc098e44f..d3f964639d3ae44249907f83cc87404154dd0252 100644 (file)
@@ -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);