Use locale-aware value for \watch in 005_timeouts.pl

Reported-by: Alexander Lakhin
This commit is contained in:
Alexander Korotkov 2024-03-15 21:35:18 +02:00
parent 196eeb6b2f
commit 605062227f
1 changed files with 11 additions and 7 deletions

View File

@ -3,6 +3,8 @@
use strict; use strict;
use warnings; use warnings;
use locale;
use PostgreSQL::Test::Cluster; use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils; use PostgreSQL::Test::Utils;
use Time::HiRes qw(usleep); use Time::HiRes qw(usleep);
@ -35,14 +37,16 @@ my $psql_session = $node->background_psql('postgres');
# The following query will generate a stream of SELECT 1 queries. This is done # The following query will generate a stream of SELECT 1 queries. This is done
# so to exercise transaction timeout in the presence of short queries. # so to exercise transaction timeout in the presence of short queries.
# Note: the interval value is parsed with locale-aware strtod()
$psql_session->query_until( $psql_session->query_until(
qr/starting_bg_psql/, q( qr/starting_bg_psql/,
\echo starting_bg_psql sprintf(
SET transaction_timeout to '10ms'; q(\echo starting_bg_psql
BEGIN; SET transaction_timeout to '10ms';
SELECT 1 \watch 0.001 BEGIN;
\q SELECT 1 \watch %g
)); \q
), 0.001));
# Wait until the backend enters the timeout injection point. Will get an error # Wait until the backend enters the timeout injection point. Will get an error
# here if anything goes wrong. # here if anything goes wrong.