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 1q8dci-0000AO-L6 for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Jun 2023 09:14:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q8dcg-0000fB-DN for pgsql-bugs@arkaria.postgresql.org; Mon, 12 Jun 2023 09:14:02 +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 1q8dcg-0000bV-4G for pgsql-bugs@lists.postgresql.org; Mon, 12 Jun 2023 09:14:02 +0000 Received: from lahtoruutu.iki.fi ([2a0b:5c81:1c1::37]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q8dcc-001lA4-EO for pgsql-bugs@lists.postgresql.org; Mon, 12 Jun 2023 09:14:00 +0000 Received: from [192.168.1.115] (dsl-hkibng22-54f8db-125.dhcp.inet.fi [84.248.219.125]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4QfmFs6jjjz49Q1Q; Mon, 12 Jun 2023 12:13:53 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1686561234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QxO3KF1pW1oacW8kHqh7EyXoWAVNs7QPBN4YVC7vdF8=; b=ZOqQStWu/95QfmGVJmnQXprFJrYgXXGSCeKRyNgO+tHPX76Z0pFIRMIc4x/diXO7Mf8TvI 6y1XbUjWStKHlWdFNgU90dgsUBd/FZBd9LK4XZ0SLicmxRNKH/6y/B9beO095xwmYa2h8h zFLIYk8ZqRBHFjYiJ7Yt+qCkRE5x+/pbV9WIx3N3ZkP/jsiKiFpN69k6wv2+gb5WG2/B+h WuEHNHHfN+0LZGY67Mbw9cbptJ8xRLuU12wbQZPh6o4Cj5aC2FVBb/tBEjIDqwI9bxB/OA 6DesfqUXW1wLUIXda0qmgSoFkgrQ8W0x2087yJRL5JSlmFP3LBuHAwnhcdZDPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1686561234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QxO3KF1pW1oacW8kHqh7EyXoWAVNs7QPBN4YVC7vdF8=; b=ee6uwuMpF/6x8zqgscST2akLij7sw6rKSU3NPNvaT793sVob6h4/Jcsrp8RR65VONsrLeV YGu6wevVYu4GwgaQ5nnML59zyqSuohYcn0zkJe0J85PpSBK3CwkL5swkHsh37GZ31H14fG 5PGrYRdQbTdQ8LCYtgr0WROK1MfjWEyDjBWld924DqxyGxUx/kzaoImCzu/Iai+mIzSXxF 385m/L/COqQ9pM7Cu63Tm9LF2NfQi8u+r96TG9lTKvqLLlbdmpjOZ4x1/vqVYoZPH8D2Fb IYWjLddUhiU/grk4PJMJv+Nn6gTeqXkOsGxinrAuEgohJ0ghOpqYvA8W0ul1ZQ== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1686561234; a=rsa-sha256; cv=none; b=TxMuGSAJQQvxA1WUDVArE+bXq3UUMVRMq2XSsts7oR8JBxH2f8xktQKWbV8vTDi4hSVqJ9 Sc6PfkHOdufgqfMausDSPwHIkc6a/rsq9LijS2gex6+dIMONf1kYhp8XbyS6j4Lq7TFmMq Stc0SkEJyQQS3i38uHs8LsodjM04Rgmcdl0pRvbln8JROio1EKRdzYI7c/fJL0tlFT6RP1 RT6kLr/NF5VFj/rZrOfwlDbDw5PEG+mzO3MnQ7rWPRKpsg4GI3UxyKDIoW/rPC5TA/YS+6 ANW4HDHd5xNPLrK4TaPFy/PixlWfpzwukpubJDC1qxA5yKIsg1uOGMnBNX84ZQ== Message-ID: <49dfcad8-90fa-8577-008f-d142e61af46b@iki.fi> Date: Mon, 12 Jun 2023 12:13:53 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG Content-Language: en-US To: Joe Conway Cc: Tristan Partin , gdo@leader.it, pgsql-bugs@lists.postgresql.org, Tom Lane References: <17946-3e84cb577e9551c3@postgresql.org> <1564676.1685043220@sss.pgh.pa.us> <555bb26e-c27c-ab65-028f-3fd5b82df9de@iki.fi> <5676b739-0854-f924-4b97-466e3504c692@joeconway.com> <665279.1686422574@sss.pgh.pa.us> <574a1afa-5c6e-829c-0fed-a9ff44719f9f@joeconway.com> From: Heikki Linnakangas In-Reply-To: <574a1afa-5c6e-829c-0fed-a9ff44719f9f@joeconway.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/06/2023 22:28, Joe Conway wrote: > On 6/10/23 15:07, Joe Conway wrote: >> On 6/10/23 14:42, Tom Lane wrote: >>> Joe Conway writes: >>>> 5/ The attached fixes the issue for me on pg10 and passes check-world. >>>> Comments? >>> >>> The call in PGLC_localeconv seems *very* oddly placed. Why not >>> do that before it does any other locale calls? Otherwise you don't >>> really have reason to believe you're saving the appropriate >>> values to restore later. >> >> >> As far as I can tell it really only affects localeconv(), so I tried to >> place it close to those. But I am fine with moving it up. > > This version is against pg16 (rather than pg10), moves up that hunk, > mentions localeconv() in the comment as the reason for the call, and > fixes some whitespace sloppiness. I will plan to apply to all supported > branches. > > Better? The man page for uselocale(LC_GLOBAL_LOCALE) says: "The calling thread's current locale is set to the global locale determined by setlocale(3)." Does that undo the effect of calling uselocale() previously, so if you later call setlocale(), the new locale takes effect in the thread too? Or is it equivalent to "uselocale(LC_ALL, setlocale(NULL))", so that it sets the thread's locale to the current global locale, but later setlocale() calls have no effect on it? In any case, this still doesn't feel like the right place. We have many more setlocale() calls. Shouldn't we sprinkle them all with uselocale(LC_GLOBAL_LOCALE)? cache_locale_time() for example. Or rather, all the places where we use any functions that depend on the current locale. How about we replace all setlocale() calls with uselocale()? Shouldn't we restore the old thread-specific locale after the calls? I'm not sure why libperl calls uselocale(), but we are now overwriting the locale that it sets. We have a few other uselocale() calls in pg_locale.c, and we take care to restore the old locale in those. There are a few uselocale() calls in ecpg, and they are protected by HAVE_USELOCALE. Interestingly, the calls in pg_locale.c are not, but they are protected by HAVE_LOCALE_T. Seems a little inconsistent. -- Heikki Linnakangas Neon (https://neon.tech)