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.96) (envelope-from ) id 1wzN03-003yao-0i for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Aug 2026 23:25:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wzN02-00GRxv-0i for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Aug 2026 23:25:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wzN01-00GRxn-2y for pgsql-hackers@lists.postgresql.org; Wed, 26 Aug 2026 23:25:41 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wzMzz-00000001S84-41s8 for pgsql-hackers@postgresql.org; Wed, 26 Aug 2026 23:25:41 +0000 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-38511175ad3so99408a91.2 for ; Wed, 26 Aug 2026 16:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1787786737; x=1788391537; darn=postgresql.org; h=user-agent:in-reply-to:content-disposition:content-type :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to:content-type; bh=9N5VatO19q7xWY1XFp/MF0vOmhmVlQQ+iuIR9pR7PII=; b=QaHwEvJgOJveR97GCxZ/ibzf7xz4bXO3G20yepnqZUOLWNFx/M+oYX4gvyt3O7ik2Z bW8DlSpOgcoBbz8zxUnEmjb/3IZUAGkg44wRanPyV7GC1z/89yZPWSyzGWuBsrUKnEVy Drc7HgEwH0gTDXJkliu6GesdcC12p6L5bbp9A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787786737; x=1788391537; h=user-agent:in-reply-to:content-disposition:content-type :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9N5VatO19q7xWY1XFp/MF0vOmhmVlQQ+iuIR9pR7PII=; b=TsuZwqUM5EEBxb0i4p+1dneqc93y2fL9gD9oX58gOuW+J+D0HPqYL49gGrs6pDz6GM tWWprjr2cYyfLHuKF47WhlYHUraIf6wBEC3L/8K9CagWYlEXYW2scphIVnH1QawcvjPD R2Q0WMZyWP/tgZjAMqSj9owhdWpSHoJ4xCFe9VfixIitjQWjhnTRDFDGK1SiJJYj25Rj HNn5mvmk8vlj9QVsHD+i4/wn5F4GpQMmbm/WmGUj3c41yH2h1cufLbcdRPz511e5toEF 2ukxwicYfGpzCsjoUAttLuWTftwvy9/9BDp/OzpclewMBGJptjsJmeQyR7ZGJbFAlTei TVkg== X-Forwarded-Encrypted: i=1; AHgh+RqI1ZqUqD5EAzMsZJB+7PsNSlkuOq+NG934iQuAFLJ09YOdAAKg8EuU1sW0Pyc3Qzi1hh6AvTiAwHkCC60r@postgresql.org X-Gm-Message-State: AFuF++n93heMdkrqdSTNhQ9KYfssyuGLp30yOYJ9DCKNV7az+LM0WEib lwnHLPLhrVqT9Sx72vx5VIvZyMn4TiZUlWSG1Y4QvSOceiMODUZqz3i6zLT8cmNxpQ== X-Gm-Gg: AR+sD13LXcPI4wmlsqPB7wvk1aaukBWqHBzu4oN1g21iD954jsEk4G1qFLfUVcqyDM5 h6JQcl2aqHLJZ6xl377EW0c3gihsVY6X7iGOeVpp+qyHQb74LZ8361bmC6fofnxdqQjnbWcmapB kwf2E7ezpiKuJ4s5diJ5Ig3Hp4UoCp0sX/VRHmzUVmGt3+YnAfni2a8IoGgTMQtqDrdYp4sMmjJ WOopE8D6Wp1oSI1ci20pNFGH4B5SW9rr6c+8nfBEr9zpj2VOfHmiBpU0o+3xp/kXiB2FVrh6WjN 572Adk+5fUbD/Iw2uZTw0SE5ar5v6LfnTzw3FvJgwmJ/ygeDkhbNOd2YL+v2U7cQo04iFO96geW nAc6cKhb+L8afpchA9Bj3M8KnVqIFe/CJ32vL/sauYO5+xOaAvx1z2cF1CDYyCHVw9fjrhdpBRk V0rz/qqp659nmIC5ecMV46qGAMcO+1yz09dx2aSG2q9gRS+tufZK5FEmPm4GcoEdeCkgw0MPsZA 41XJ7HnCGFRni7nVAH4 X-Received: by 2002:a17:90b:4c09:b0:37f:e177:f58 with SMTP id 98e67ed59e1d1-3966d3dcdb1mr19982036a91.9.1787786737075; Wed, 26 Aug 2026 16:25:37 -0700 (PDT) Received: from microsoft.com (c-73-15-160-255.hsd1.ca.comcast.net. [73.15.160.255]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3283d9e5fb1sm19711099eec.25.2026.08.26.16.25.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2026 16:25:36 -0700 (PDT) Date: Wed, 26 Aug 2026 16:25:34 -0700 From: Noah Misch To: Jeff Davis Cc: Daniel Verite , Thomas Munro , Peter Eisentraut , Tom Lane , pgsql-hackers@postgresql.org Subject: Re: Remaining dependency on setlocale() Message-ID: <20260826232534.13.noahmisch@microsoft.com> References: <5e709c7a-0504-426c-8a7d-e0701c334cd7@manitou-mail.org> <36dc305c6445970f7680dbba63cf9b32a5e91d27.camel@j-davis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <36dc305c6445970f7680dbba63cf9b32a5e91d27.camel@j-davis.com> User-Agent: Mutt/2.3.0 (2026-01-25) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Nov 03, 2025 at 11:59:57AM -0800, Jeff Davis wrote: > On Mon, 2025-11-03 at 20:14 +0100, Daniel Verite wrote: > > No, I think we should put the database's lc_ctype > > into LC_CTYPE and the database's lc_collate into > > LC_COLLATE, independently of anything else, > > like it was done until commit 5e6e42e. > > I believe that's the purpose of these database > > properties, whether the provider is libc or ICU or builtin. > > Is there a clean way to document this behavior? I have tried to improve > the documentation in this area before, but it's not easy because the > behavior is so nuanced. While documenting it is feasible, documentation is a poor replacement for retaining longstanding and useful behavior. > Reverting commit 5e6e42e may be the right thing, but I'd like to hear > what others have to say on this point first. I think a revert would be the better thing. The stated reason for the commit was "avoid accidentally depending on libc behavior when using a different provider". Such an accident gets LANG=C behavior, but that's still easy to miss. The accident remains silent. To achieve your reasonable goal of detecting such accidents, I'd prefer something more like a test with an LD_PRELOAD DSO that poisons setlocale-dependent functions to elog or abort(). If nothing else, the release notes would need to mention this commit. > In particualr, I'd like to > know whether such a revert is based on principle, a practical problem, > or just an abundance of caution. In this taxonomy, I would call it an abundance of caution, combined with commit 5e6e42e not moving the needle much toward its goal of avoiding accidents. In other words, I agree with this: On Mon, Nov 03, 2025 at 08:14:03PM +0100, Daniel Verite wrote: > Forcing "C" is a disruptive change, that IMO does > not seem compensated by substantial advantages > that would justify the disruption. Also important to me: the disruption is silent. Applications are on their own to even figure out the change affected them. On Mon, Nov 10, 2025 at 12:39:28PM -0800, Jeff Davis wrote: > On Mon, 2025-11-03 at 20:14 +0100, Daniel Verite wrote: > > No, I think we should put the database's lc_ctype > > into LC_CTYPE and the database's lc_collate into > > LC_COLLATE, independently of anything else, > > like it was done until commit 5e6e42e. > > I believe that's the purpose of these database > > properties, whether the provider is libc or ICU or builtin. > > As phrased, that appears to be a promise that we will never support > thread-per-connection. setlocale() is not thread-safe, and uselocale() > is not available on NetBSD. That's one way to harmonize Daniel's vision with NetBSD, but I wouldn't do it that way. NetBSD has chosen not to implement this POSIX-defined interface. PostgreSQL should confine the consequences of NetBSD's decision to NetBSD, not treat it as a constraint on PostgreSQL elsewhere. For thread-per-connection, I'd likely just document that uselocale()-lacking systems leave all threads at the postmaster's setlocale(LC_ALL, "") and that it's intended to be noticeable only in non-PostgreSQL code like Perl.