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.94.2) (envelope-from ) id 1s03lH-000TVr-7H for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Apr 2024 18:23:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s03kG-001emK-2K for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Apr 2024 18:22:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s03kF-001emC-JO for pgsql-hackers@lists.postgresql.org; Thu, 25 Apr 2024 18:22:56 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s03kC-0002Ok-Ur for pgsql-hackers@postgresql.org; Thu, 25 Apr 2024 18:22:55 +0000 Received: from [172.30.1.254] (unknown [172.30.1.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: a.voloshin@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 72C89E20E95; Thu, 25 Apr 2024 21:22:50 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1714069371; bh=whAn+GFfPSp5a1jy64uui52T8sm0znutJKoQAovbIZE=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=D8j5sNb7Z9CCnQ4656czMZzxzExUsq9iDp6VhUYNYxwMejHVj7ovihJ6U918k0Iqg 3bwSUDdmSa3uB5LOPrMvHjLq5XCG9+V+r5k1L9PlZwd+7Mzn9FvpHHBE4Zd2svox7i 2CZFdykqT+dkALeDe6RNA93I/vkbtArT7+5hEYgt24cAl4//dj8WOe3/pCY9ec5ep6 mnzya2Y4KVcXoaX2TKICRELz/RjcOvhqfHLjMQGi52UgNmieNfqSF54dF0GGOooHdh fQ1iF16XsJE3xNFsoPMkKY8VOsKRobZ3pVvFGt0laWa+rAazrMAfKfGfOyUuaK6qHc z0hZ0iVoS1zRg== Content-Type: multipart/mixed; boundary="------------OeK6K9dzy90gals121h1Bu0W" Message-ID: <5ed7d3e2-ca7e-40ad-9de9-e7648576cc01@postgrespro.ru> Date: Thu, 25 Apr 2024 21:22:49 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pgsql: psql: add an optional execution-count limit to \watch. To: Pg Hackers Cc: Alexander Korotkov , Andrew Dunstan , Tom Lane , Aleksander Alekseev References: <2929174.1680876023@sss.pgh.pa.us> <4032363.1681134882@sss.pgh.pa.us> <4076950.1681139381@sss.pgh.pa.us> <2748103.1681839252@sss.pgh.pa.us> Content-Language: en-US From: Anton Voloshin In-Reply-To: <2748103.1681839252@sss.pgh.pa.us> X-KSMG-AntiPhishing: NotDetected, bases: 2024/04/25 17:25:00 X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2024/04/25 16:41:00 #24970177 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------OeK6K9dzy90gals121h1Bu0W Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hello, hackers. On 18/04/2023 20:34, Tom Lane wrote (on pgsql-committers): > I shall now retire to a safe distance and watch the buildfarm. Unfortunately, on fresh perl (5.38.2 verified) and on ru_RU.UTF-8 locale, it breaks basic float comparison: 0 < 0.5 is no longer true. This is the reproduction on REL_16_STABLE (but it affects master as well), using fresh Ubuntu 24.04 container. 0. I've used lxc to get a fresh container: $ lxc launch ubuntu-daily:noble u2404 But I don't think lxc or containerization in general matters in this case. Also, I think any environment with fresh enough Perl would work, Ubuntu 24.04 is just an easy example. (obviously, install necessary dev packages) 1. Generate ru_RU.UTF-8 locale: a. In /etc/locale.gen, uncomment the line: # ru_RU.UTF-8 UTF-8 b. Run locale-gen as root. For me, it says: $ sudo locale-gen Generating locales (this might take a while)... en_US.UTF-8... done ru_RU.UTF-8... done Generation complete. 2. Apply 0001-demo-of-weird-Perl-setlocale-effect-on-float-numbers.patch (adding src/test/authentication/t/999_broken.pl) 3. Run the test LANG=ru_RU.UTF-8 make check -C src/test/authentication PROVE_TESTS=t/999_broken.pl PROVE_FLAGS=--verbose The test is, basically: use PostgreSQL::Test::Utils; use Test::More tests => 1; ok(0 < 0.5, "0 < 0.5"); If I comment-out the "use PostgreSQL::Test::Utils" line, the test works. Otherwise it fails to notice that 0 is less than 0.5. Alternatively, the test fails if I replace that "use" line with BEGIN { use POSIX qw(locale_h); setlocale(LC_NUMERIC, ""); } "BEGIN" part is essential: mere use/setlocale is fine. Also, adding use locale; or even use locale ':numeric'; fixes the test, but I doubt whether it's a good idea to add that to Utils.pm. Obviously, one of the reasons is that according to ru_RU.UTF-8 locale for LC_NUMERIC, fractional part separator is ",", not ".". So one could, technically, parse "0.5" as "0" and then unparsed ".5" tail. I think it might even be a Perl bug, because, according to my quick browsing of man perlfunc (setlocale) and man perllocale, this should not affect the code outside "use locale", not in such a fundamental way. After all, we're talking not about strtod etc, but about floating-point numbers in the source code. P.S. $ perl --version This is perl 5, version 38, subversion 2 (v5.38.2) built for x86_64-linux-gnu-thread-multi (with 44 registered patches, see perl -V for more detail) P.P.S. I'm replying to pgsql-hackers, even though part of previous discussion have been on pgsql-committers. Hopefully, it's OK. -- Anton Voloshin Postgres Professional, The Russian Postgres Company https://postgrespro.ru --------------OeK6K9dzy90gals121h1Bu0W Content-Type: text/x-patch; charset=UTF-8; name="0001-demo-of-weird-Perl-setlocale-effect-on-float-numbers.patch" Content-Disposition: attachment; filename*0="0001-demo-of-weird-Perl-setlocale-effect-on-float-numbers.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSA2ZDE3MTlkZTQ5YjFjNjkwZTFmYjdhZWVkOGZjNzYwZjA1M2EyYTMxIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBBbnRvbiBWb2xvc2hpbiA8YS52b2xvc2hpbkBwb3N0 Z3Jlc3Byby5ydT4KRGF0ZTogVGh1LCAyNSBBcHIgMjAyNCAxNzoyMzoyNiArMDAwMApTdWJq ZWN0OiBbUEFUQ0hdIGRlbW8gb2Ygd2VpcmQgUGVybCBzZXRsb2NhbGUgZWZmZWN0IG9uIGZs b2F0IG51bWJlcnMKIGNvbXBhcmlzb24KCi0tLQogc3JjL3Rlc3QvYXV0aGVudGljYXRpb24v dC85OTlfYnJva2VuLnBsIHwgOCArKysrKysrKwogMSBmaWxlIGNoYW5nZWQsIDggaW5zZXJ0 aW9ucygrKQogY3JlYXRlIG1vZGUgMTAwNjQ0IHNyYy90ZXN0L2F1dGhlbnRpY2F0aW9uL3Qv OTk5X2Jyb2tlbi5wbAoKZGlmZiAtLWdpdCBhL3NyYy90ZXN0L2F1dGhlbnRpY2F0aW9uL3Qv OTk5X2Jyb2tlbi5wbCBiL3NyYy90ZXN0L2F1dGhlbnRpY2F0aW9uL3QvOTk5X2Jyb2tlbi5w bApuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwMDAwMC4uZTY1YTI3MmUxY2IK LS0tIC9kZXYvbnVsbAorKysgYi9zcmMvdGVzdC9hdXRoZW50aWNhdGlvbi90Lzk5OV9icm9r ZW4ucGwKQEAgLTAsMCArMSw4IEBACit1c2Ugc3RyaWN0OwordXNlIHdhcm5pbmdzIEZBVEFM ID0+ICdhbGwnOworCit1c2UgUG9zdGdyZVNRTDo6VGVzdDo6VXRpbHM7CisKK3VzZSBUZXN0 OjpNb3JlIHRlc3RzID0+IDE7CisKK29rKDAgPCAwLjUsICIwIDwgMC41Iik7Ci0tIAoyLjQz LjAKCg== --------------OeK6K9dzy90gals121h1Bu0W--