pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Peter Eisentraut <peter@eisentraut.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Remaining dependency on setlocale()
Date: Tue, 14 Oct 2025 16:26:47 -0700
Message-ID: <b555e9895fce1fae896bbada4c01a5872739a7dc.camel@j-davis.com> (raw)
In-Reply-To: <aa110f8605e8b6b81b18fcde2464245123f9fc6f.camel@j-davis.com>
References: <4c5da86af36a0d5e430eee3f60ce5e06f1b5cd34.camel@j-davis.com>
	<1841102.1722982989@sss.pgh.pa.us>
	<CA+hUKGK7qKDHgoh1HuvMhtcpAwwVBA5BDt33vCzYYqCLfQTtzw@mail.gmail.com>
	<CA+hUKGLLTy155HTQ6HfHu5-XPNfoFgDsRVUWevj+O6p3UmvPkg@mail.gmail.com>
	<a70d3db4b8291b61c6937c0c003aa70e2d2c3a9a.camel@j-davis.com>
	<CA+hUKGL82jG2PdgfQtwWG+_51TQ--6M9XNa3rtt7ub+S3Pmfsw@mail.gmail.com>
	<b19ea499a6d78c101dc55b61bfb42069b427445c.camel@j-davis.com>
	<fa04b56430fa4b5da7311c2faa113f406c6d192a.camel@j-davis.com>
	<CA+hUKGKcS-Zhi8Ud+tv2TanzXBQjH+WsLyPY9DUDXob5VoYAtg@mail.gmail.com>
	<cd3517c7-ddb8-454e-9dd5-70e3d84ff6a2@eisentraut.org>
	<d2e7d63c0cc98f425652527cf260a3e6da17d2b0.camel@j-davis.com>
	<a1396f17f462ee6561820f755caaf2d12eb9fd15.camel@j-davis.com>
	<9875f7f9-50f1-4b5d-86fc-ee8b03e8c162@eisentraut.org>
	<a8666c391dfcabe79868d95f7160eac533ace718.camel@j-davis.com>
	<6956823dd669abc64183fc91e64dc2e56e31f3ea.camel@j-davis.com>
	<ed394f839d813762ddcd65cfcab0e062f8b5e0b1.camel@j-davis.com>
	<CA+hUKGLYcbnHBXhHk_OFwZ03LE+D=cAirm7TVN8fMhT9rgcTbA@mail.gmail.com>
	<f040113cf384ada69558ec004a04a3ddb3e40a26.camel@j-davis.com>
	<CA+hUKGJxSDFcTZSGi++PTC=jM49q1oK=v7Lcdf96VQXXvLhoow@mail.gmail.com>
	<cdd20efc0f5418c597791a1e3a5abb68fa3ce35b.camel@j-davis.com>
	<aa110f8605e8b6b81b18fcde2464245123f9fc6f.camel@j-davis.com>

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






view thread (96+ messages)  latest in thread

Message-ID: <b555e9895fce1fae896bbada4c01a5872739a7dc.camel@j-davis.com>
Permalink:  ../b555e9895fce1fae896bbada4c01a5872739a7dc.camel@j-davis.com/
Also on:    postgresql.org/message-id/b555e9895fce1fae896bbada4c01a5872739a7dc.camel@j-davis.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: pgsql@j-davis.com, thomas.munro@gmail.com, peter@eisentraut.org, tgl@sss.pgh.pa.us
  Subject: Re: Remaining dependency on setlocale()
  In-Reply-To: <b555e9895fce1fae896bbada4c01a5872739a7dc.camel@j-davis.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox