Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wtkj6-000Dis-1T for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Aug 2026 11:33:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wtkj4-002Pb9-17 for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Aug 2026 11:32:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wtkj4-002Pb1-01 for pgsql-hackers@lists.postgresql.org; Tue, 11 Aug 2026 11:32:59 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wtkj3-000000006Od-1XwM for pgsql-hackers@lists.postgresql.org; Tue, 11 Aug 2026 11:32:58 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-6a157f90752so4097987a12.3 for ; Tue, 11 Aug 2026 04:32:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786447976; x=1787052776; darn=lists.postgresql.org; h=content-type:mime-version:user-agent:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=9lTjOjAVe4QlyFKY2DUVyEJ/2FQjfz/GQ/SxEbs6eXQ=; b=LjKNRH3CNEQj4keShgykGiVQbmDV6qglYJrCSneBK0aDXpWmfNvls2bD3hkIjxtTlw 3nBZ5Wbadd/758JVlIWglIhVtYHZHIDb0XrZCODZkykH2PxQpxlKl52+aYl3nL9kRdUB MISHA8NTzRtEJc0eM3OEkeZciiBUwdYeMSC+DFlnhwyyc2KGqNTrZWeVKpe0YuzoUkH4 yyck/n/2aCqQPKpFadHen8q9Y6S8mtZacSnl5x17+uEt0EGe8pXjqZYEMAMQM2uX8VEh 12tWDJ3UONwldNJNBz1AbPeDOWqm1u+2cx9Mq/wztSKuCijdZwqXOsqALJGcxyfR+Ltz RTpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786447976; x=1787052776; h=content-type:mime-version:user-agent:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=9lTjOjAVe4QlyFKY2DUVyEJ/2FQjfz/GQ/SxEbs6eXQ=; b=RQwpN1MoSnQgAiq/AcRCHTEKRriwwt32BJnbrI3YgfWl4Agfe39QKohmLKJF4JK6SN oAA5KGfH0ZzN6Cqk/PWkAo6PRctnI+4Da5kgjRx1Zr0DbAxfw2wLkNzqXWGTdXgeBCd1 7losh5SY9cEcddCm2fm6sphq8WiqjF/iSObH97YYofp2F1m3CFEH6qCkoYSeaNqflJH+ NO0Q6sPaZW8duWYDCxG6TvXQFGvUF7Ct4QU7QwTzeQHTiZtkT19fKyksWoARpd1smorO gqspYIqxW1muQjVbvNBfscPVFyhPIJ+pF3KovjXRejpB8xuwz5qqPlRfm56PNPq4hnvk XPIg== X-Gm-Message-State: AOJu0YxBaeQEd63D4PsBJafVBYHhJKYPlVFhjgNy71gqdkfsDg5/JyJs wxlA+Inl7nltJjASYuyfDoRBNugIM3pQkTC1hdQ+Ulh4qwe9If/cGns= X-Gm-Gg: AR+sD13T8Fu5WRf9K1jVMwOR2FGEtS+Ntrl1YQN5n3QMGJD28zOhBtUvdhVxB7hzkQ3 2hpoYK6DKqbR71qFstMsNQl+BNS/ZNkB8pGuRXzIqBPYFbrkurW8i6QK8vQV7gzvSANDopLT8Gi F6VanqD0CwUROK47HQkeDP9+X/5WcguL46WoW31GrJ13QvOZTGRSR/kAldZSh5U8Po3ooKPXspn Myo2hVWrXblf+UqpHz+AD20+LGL2gsPXKIuaUTIPlSDSJXEEgPjuzFCzElaTf2NxsBB0v0XkBDY oo4L2pnn36MA9jUjMLmvOvuKTArM0IzG9067gt6lmYu9BlAhw7ZwA+g5MoK5TXH4pCHxwRjYzQ8 T9HyOF9L4OSgijZFaHZfS5HF5ZER9WZ53NewWHOu1d9GrUiYxUU/7tMK/o14f5/FcqG9hqvafuk +G+Gy9xJI9hzLqcUJ1Y4xnU4rLK+gTs7W5KhkKoFZGL68XnnxwXMjmf3aB5vMDTWzQhJM= X-Received: by 2002:a05:6402:4613:b0:6a1:ab16:5c05 with SMTP id 4fb4d7f45d1cf-6a364527f8bmr1452207a12.19.1786447975596; Tue, 11 Aug 2026 04:32:55 -0700 (PDT) Received: from localhost ([2a00:6d43:908:5803::3]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a362d7d590sm555724a12.0.2026.08.11.04.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2026 04:32:53 -0700 (PDT) From: "Jonathan Gonzalez V." X-Google-Original-From: "Jonathan Gonzalez V." To: Bryan Green Cc: pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH] Avoid uninitialized-value error in poll_query_until timeout diagnostic In-Reply-To: <0f515c6d-6032-4c5f-80ac-5c78faae9522@gmail.com> (Bryan Green's message of "Sat, 8 Aug 2026 21:59:57 -0500") References: <0f515c6d-6032-4c5f-80ac-5c78faae9522@gmail.com> Date: Tue, 11 Aug 2026 13:32:51 +0200 Message-ID: <87a4qs3na4.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello!! Bryan Green writes: > ... > Cluster.pm runs under "use warnings FATAL => 'all'", so when $query is > undefined this does not warn, it dies with "Use of uninitialized value > $query in concatenation". The result is that a timeout in a connection only > poll fails with an uninitialized-value error instead of printing the timeout > diagnostic the code is trying to produce, hiding the actual failure. > > $ perl -e 'use warnings FATAL => "all"; my $q; my $s = qq(q: $q);' > Use of uninitialized value $q in concatenation (.) or string at -e line 1. This was a little bit tricky to reproduce, but I used the following line: perl -I src/test/perl -MPostgreSQL::Test::Cluster -MPostgreSQL::Test::Utils -MTest::More -e 'local $PostgreSQL::Test::Utils::timeout_default=0.1; my $n=PostgreSQL::Test::Cluster->new("poll_repro",install_path=>"$ENV{PWD}/build/tmp_install/usr/local/pgsql");ok(!$n->poll_query_until("postgres", undef, ""), "connection-only timeout"); done_testing();' I wasn't able to reproduce this in a test, so this make sense to happen only if there's any failure during one of the tests, but this snippet proved the failure exists. > The fix uses a fallback string when the query is undefined: > > my $msg_query = $query // '(undef - connection attempt only)'; > > and interpolates $msg_query instead. Test-only, one line. What about using the most common way in the code instead of using `//` operator? Something like: my $msg_query = '(undef - connection attempt only)' unless defined $query; This is how is done everywhere else and is a bit more clear than the `//` operator which looks pretty tricky even for Perl Regards, -- Jonathan Gonzalez V. EDB https://www.enterprisedb.com