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 1v8oPv-004Lnz-4R for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Oct 2025 23:26:54 +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 1v8oPu-003M1R-4o for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Oct 2025 23:26:53 +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 1v8oPt-003M1J-Kh for pgsql-hackers@lists.postgresql.org; Tue, 14 Oct 2025 23:26:52 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v8oPq-001nLb-1m for pgsql-hackers@postgresql.org; Tue, 14 Oct 2025 23:26:51 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-789fb76b466so5449796b3a.0 for ; Tue, 14 Oct 2025 16:26:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1760484409; x=1761089209; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=ovdSh9yozqcpY0xtoMeDucyC9NyMRq7xreMnvfUle7M=; b=Krvknlp54KDPuB5b1eW9XafBMOkqHraTYwYgzTZaZaOptnV9imo2q7CZ7ThSrnF1oz bGaD1hMXSx+lVvTKDgBM4mhR3J161Hn5sJVluDKVV+18TQAkEla0eJmQxLg4k99OKbfM /U1pX6DN1r2y47TDcmMoXpb9e+XndakIoRbvdJrtgqQuBrsemztA7m6sNbaZvRnHpbjc 0TDiW3gxOGvAb2gfXbsXJwgV7/Vrz6fCeZLk8aUKfzEbr83poHSBGWkBPaZNFP2rkCZy k1DtzvREBsLSwDkV7A/j4PQOz5mQyJRICw1RunIhxeKptIaLvRRc4E4WNHdGfgdrc4mm y4jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760484409; x=1761089209; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ovdSh9yozqcpY0xtoMeDucyC9NyMRq7xreMnvfUle7M=; b=HawXJzaOhrKEptYhpTFcV4e7EC6tjDGdutda2jEbVJLejDmIJ5rK+B35bYL0e7Lye4 cDpfm6NjG897euPaMkbKfbpaN538P5I8X3rDLJQI32iS+JTeM18u869nA3v+UZNJLUGV QMwKZKr7RPqqT5E1St7dSFiRTAwsxl8Y/O6tCmZVY3YXX1cQNGQBFe4iewoexZosTVNw YV1A2in6AqkG1C8QFHk86P8k/o6kUsWLTrf1tHce2ZfQhhAqX2KBnwelZRWEnoGva039 KSbma4Xxr/kDY9WY2mvSIobH7YV3YP3tKXZdYy08gzSWeW7nt7TGLt5DqSTZEVzVHnuY n61w== X-Forwarded-Encrypted: i=1; AJvYcCXWZnAcJUlypCDa3e2e3BDMTxGWbPNUvM1eqrXNpD7696zzkbNMtg9rrrJWGTkHr0k8X79RQNJu5/eQjaLR@postgresql.org X-Gm-Message-State: AOJu0YxQkDdS0wLsMSMG510akbejxvl+Aa2kzJ9LmRqEke8hFGZ4c2eV pxwUwn1ElqJh/cAy2Lp5Vsnj1P6Dz/HrEFEeIT9ZrJBNv/egyn8l/hVx6ebMnEMXKw== X-Gm-Gg: ASbGncsHUhQumPEYV0qlA7xDF0rlU/zyJ+SoqQYTYKeh/5cC4wUSD0M/8UUEUhFQ6pO rlYSWIkW0hSyjkwwnee/Ee4ISg+CZMobYqsNgNFtNZNyey+KgAmPK2opdHhmh/yyP/aWo6ZjNXN PtQ3o6qR7ragtRkXireLu4tGhCkKX3SiZZITmLMcxN0DdySgnO/4DaTQeq9zDYeYq5un+MJ5by9 yU9xcAXOVvp1BeLrqgewNYgWe04HFUKjXR4ZoHygG6uD7xJC3UdJO/A1DaOTSAlSWE02BBkD1EJ 0Q+8Gik0x0xNpYdx9mpJ1sMgmLXPgg6OlR0BJgK4GX8Yg59R/COAfAInKcUxkbo0BrVM8ahULtU K07Jm79/yoHL2Bm6dG/JhmNcVCVFppS1xm5vUscvSN7cc7VK66qF0gobzW/yw7D8v3BAPt4u0OM OKX1NenmGDlhLHIKXPNdM= X-Google-Smtp-Source: AGHT+IE9NP8m7HGV6qrCnSNzpnXBqHuaHAM1vjTRvX21Kv4UUGlZewJWnRS3zxadNIKanMNjVZ03bw== X-Received: by 2002:a05:6a21:3299:b0:306:51fd:5542 with SMTP id adf61e73a8af0-32da8461d0emr32203879637.44.1760484409082; Tue, 14 Oct 2025 16:26:49 -0700 (PDT) Received: from jeff-ws-bridge.lan (c-24-7-19-3.hsd1.ca.comcast.net. [24.7.19.3]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b678df233cfsm13090709a12.28.2025.10.14.16.26.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 16:26:48 -0700 (PDT) Message-ID: Subject: Re: Remaining dependency on setlocale() From: Jeff Davis To: Thomas Munro Cc: Peter Eisentraut , Tom Lane , pgsql-hackers@postgresql.org Date: Tue, 14 Oct 2025 16:26:47 -0700 In-Reply-To: References: <4c5da86af36a0d5e430eee3f60ce5e06f1b5cd34.camel@j-davis.com> <1841102.1722982989@sss.pgh.pa.us> <9875f7f9-50f1-4b5d-86fc-ee8b03e8c162@eisentraut.org> <6956823dd669abc64183fc91e64dc2e56e31f3ea.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.3-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2025-07-24 at 11:10 -0700, Jeff Davis wrote: > The main problem is with strerror_r()... Postgres messages, like "division by zero" are translated just fine without LC_CTYPE; gettext() only needs LC_MESSAGES and the server encoding. So these are fine. We use strerror_r() to translate the system errno into a readable message, like "No such file or directory", i.e. the %m replacements. That needs LC_CTYPE set (just for the encoding, not the language/region) as well as LC_MESSAGES (for the language/region). When using a locale provider other than libc, it's unfortunate to require LC_CTYPE to be set for just this one single purpose. The locale itself, e.g. the "en_US" part, is not used at all; only the encoding part of the setting is relevant. And there is no value other than "C" that works on all platforms. It's fairly confusing to explain why the LC_CTYPE setting is required for the builtin or ICU providers at all. Also, while it's far from the biggest challenge when it comes to multithreading, it does cause thread-safety headaches on platforms without uselocale(). Perhaps we could get the ASCII message and run it through gettext()? That would be extra work for translators, but perhaps not a lot, given that it's a small and static set of messages in practice. That would also have the benefit that either NLS is enabled or not -- right now, since the translation happens in two different ways you can end up with partially-translated messages. It would also result in consistent translations across platforms. Regards, Jeff Davis