Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plt9W-0002bK-S1 for pgsql-committers@arkaria.postgresql.org; Mon, 10 Apr 2023 15:09:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1plt9T-0006Ag-Tr for pgsql-committers@arkaria.postgresql.org; Mon, 10 Apr 2023 15:09:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plt9T-0006AV-MJ for pgsql-committers@lists.postgresql.org; Mon, 10 Apr 2023 15:09:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plt9M-0000tt-R7 for pgsql-committers@lists.postgresql.org; Mon, 10 Apr 2023 15:09:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 33AF9fUk4076951; Mon, 10 Apr 2023 11:09:41 -0400 From: Tom Lane To: Aleksander Alekseev cc: pgsql-committers@lists.postgresql.org, Alexander Korotkov , Andrew Dunstan Subject: Re: pgsql: psql: add an optional execution-count limit to \watch. In-reply-to: References: <2929174.1680876023@sss.pgh.pa.us> <4032363.1681134882@sss.pgh.pa.us> Comments: In-reply-to Aleksander Alekseev message dated "Mon, 10 Apr 2023 17:30:00 +0300" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <4076835.1681139300.0@sss.pgh.pa.us> Date: Mon, 10 Apr 2023 11:09:41 -0400 Message-ID: <4076950.1681139381@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4076835.1681139300.1@sss.pgh.pa.us> Aleksander Alekseev writes: >> Hmm, so psql is honoring the LC_NUMERIC setting in that environment, >> but perl isn't. For me, it appears that adding 'use locale;' to >> the test script will fix it ... can you confirm if it's OK for you? > Right, src/bin/psql/t/001_basic.pl has "use locale;" since cd82e5c7 > and it fails nevertheless. > ... > So it looks like what happens is LC_ALL overwrites LC_NUMERIC for perl > but not for psql. Oh, right, there already is one :-(. After some more research, I believe I see the problem: Utils.pm does BEGIN { # Set to untranslated messages, to be able to compare program output # with expected strings. delete $ENV{LANGUAGE}; delete $ENV{LC_ALL}; $ENV{LC_MESSAGES} = 'C'; Normally, with your settings, LC_ALL=en_US.UTF-8 would dominate everything. After removing that from the environment, the child psql process will honor LC_NUMERIC=ru_RU.UTF-8 and expect \watch's argument to be "0,01". However, I bet that perl has already made its decisions about what its internal locale is, so it still thinks it should print "0.01". I am betting that we need to make Utils.pm do setlocale(LC_ALL, ""); after the above-quoted bit, else it isn't doing what it is supposed to if the calling script has already done "use locale;", as indeed psql/t/001_basic.pl (and a small number of other places) do. The attached makes check-world pass for me under these conflicting environment settings, but it's kind of a scary change. Thoughts? regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="fix-TAP-test-locale-settings.patch"; charset="us-ascii" Content-ID: <4076835.1681139300.2@sss.pgh.pa.us> Content-Description: fix-TAP-test-locale-settings.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/Postgr= eSQL/Test/Utils.pm index 878e12b15e..4c6cde8974 100644 --- a/src/test/perl/PostgreSQL/Test/Utils.pm +++ b/src/test/perl/PostgreSQL/Test/Utils.pm @@ -43,6 +43,7 @@ package PostgreSQL::Test::Utils; = use strict; use warnings; +use locale; = use Carp; use Config; @@ -55,6 +56,7 @@ use File::Spec; use File::stat qw(stat); use File::Temp (); use IPC::Run; +use POSIX qw(locale_h); use PostgreSQL::Test::SimpleTee; = # We need a version of Test::More recent enough to support subtests @@ -102,6 +104,7 @@ BEGIN delete $ENV{LANGUAGE}; delete $ENV{LC_ALL}; $ENV{LC_MESSAGES} =3D 'C'; + setlocale(LC_ALL, ""); = # This list should be kept in sync with pg_regress.c. my @envkeys =3D qw ( ------- =_aaaaaaaaaa0--