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 1tBWYk-004OkU-Rw for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Nov 2024 09:54:42 +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 1tBWYi-002bUq-8d for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Nov 2024 09:54:40 +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.94.2) (envelope-from ) id 1tBWYh-002bUi-Sv for pgsql-hackers@lists.postgresql.org; Thu, 14 Nov 2024 09:54:40 +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 1tBWYe-001o9N-TR for pgsql-hackers@postgresql.org; Thu, 14 Nov 2024 09:54:39 +0000 Received: from [192.168.1.110] (dsl-hkibng22-50ddb7-241.dhcp.inet.fi [80.221.183.241]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4XpwVH05LYz49Pwn; Thu, 14 Nov 2024 11:54:30 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1731578072; 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=uZtXZfIapxOpLIMxG2RaOucdc0I1588ikHJMnmHcmJI=; b=rkLchs9VruwIcW4ZxmlKW4zKNc5qejmP8iGgXgS1ZYDV5jDsrFXcLu6T3IgGlyT+PBN8e3 nzejJujtSCxaswUys2ZHHWxMfmnXBrO1JeRnKMgAmxtg5jt9QBbx7/J8GZzbjvFuh+Gf3i VmCE0Z+wHdxCKLyazcHTPTaUdq0P/SxVNYwRsbm/jivGj8Oqhm+y6nbke8sn9hU9LB2xri IGq4Lbegn8DnrWfkEUTXMQePwrZMNgC4+wNSabrTCGXGg6hArvRgfOFUvmG3k6Zo5gvUoX o7/svTK6YJD3FZckqMXKdeitLoc3CVZQ1yyIzJHeZFkuvg0L7K7CysloCAp2Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1731578072; 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=uZtXZfIapxOpLIMxG2RaOucdc0I1588ikHJMnmHcmJI=; b=K0Cb/ONeYfmxfpo/+HVIO1MFtCYDoohWeb06l8QszBMOR+2CjSj+dp1SZSSdWaLlcJniFm bn1B0bXcBo5S3R95Y3nKhVU3Xypf4BjxsssUftx14iyU/JVV5dgz7+FGK9ACdCQYCe5jA3 thm28aM4WIPK3MfMPjb9NEBMbB+ZtphxjuXcGdPvTSvEFU94wOw9FFyf+Qzz3bhx/HHWYQ iBgrlNvQXACAhhrLrNkIyBT0D7P5c00WFs+HzQsDZzFFP8i6wVduT0ndqIAX3nwy0N7HVW f2KttHFiBsumRPik8oopN/BdXbQXTKK2EZWt2Wdj+TnOsb8hAepUgMoa9z5hdA== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1731578072; a=rsa-sha256; cv=none; b=ZZJT5f8XLBdKl2TmmB1JKjzyqOWzyhoxwtm6KXLTBUgstEL1XrAQHxBCx7TL5ogbfqxh5U NnzrodlKAPccWS78NqLCYZbXbDBdmt+OWYFv7kj0BTvEAbOWUmbDABw9XEAjRaBjYjXYp5 eOWfvLeBuBr/D3zYN/RgQgJ21eXlLtVEpU14tF0Sew3Nvor61ikZiOaV1XK2cRlSh5L2dA kGTxXNoNbjN/oGOrdito/JmQFM01X4q90lQMUj4pUFFCPkYz0ywdx5RTfSLmEcW4+pmE6Y EqFDc9gs7wUkx5r6D1yg5/Jm9uj9ybfSwZkfZvjYfdeez+uBNSV10a718y/GeA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi Message-ID: <8b633f12-c06f-49ce-827e-ffe23b6c0dc1@iki.fi> Date: Thu, 14 Nov 2024 11:54:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: On non-Windows, hard depend on uselocale(3) To: Thomas Munro , Peter Eisentraut Cc: Tristan Partin , Tom Lane , pgsql-hackers References: <12842.1700083028@sss.pgh.pa.us> <98824.1700089582@sss.pgh.pa.us> <664255.1700245108@sss.pgh.pa.us> <810814.1700261928@sss.pgh.pa.us> <1155474.1700433384@sss.pgh.pa.us> <1330178.1700498443@sss.pgh.pa.us> <423491f5-2eaa-454e-8dc9-037d69c1a8f9@eisentraut.org> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 14/11/2024 09:48, Thomas Munro wrote: > On Thu, Aug 29, 2024 at 6:50 AM Peter Eisentraut wrote: >> The error handling with pg_ensure_c_locale(), that's the sort of thing >> I'm afraid will be hard to test or even know how it will behave. And it >> creates this weird coupling between pgtypeslib and ecpglib that you >> mentioned earlier. And if there are other users of PG_C_LOCALE in the >> future, there will be similar questions about the proper initialization >> and error handling sequence. > > Ack. The coupling does become at least less weird (currently it must > be capable of giving the wrong answers reliably if called directly I > think, no?) and weaker, but I acknowledge that it's still non-ideal > that out-of-memory would be handled nicely only if you used ecpg > first, and subtle misbehaviour would ensure otherwise, and future > users face the same sort of problem unless they design in a reasonable > initialisation place that could check pg_ensure_c_locale() nicely. > Classic retro-fitting problem, though. Hmm, so should we add calls to pg_ensure_c_locale() in pgtypeslib too, before each call to strtod_l()? Looking at the callers of strtod() in ecpg, all but one of them actually readily convert the returned value to integer, with some multiplication or division with constants. It would be nice to replace those with a function that would avoid going through double in the first place. That still leaves one caller in numericvar_to_double() which really wants a double, though Overall, the patch looks good to me. -- Heikki Linnakangas Neon (https://neon.tech)