pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: Peter Eisentraut <peter@eisentraut.org>
To: Andreas Karlsson <andreas@proxel.se>
To: pgsql-hackers@postgresql.org
Subject: Re: tiny step toward threading: reduce dependence on setlocale()
Date: Tue, 06 Aug 2024 14:40:17 -0700
Message-ID: <23cc1f3cfcdbdd3b2d3bb956d57ae422aa9d0b9e.camel@j-davis.com> (raw)
In-Reply-To: <89475ee5487d795124f4e25118ea8f1853edb8cb.camel@j-davis.com>
References: <2228884bb1f1a02614b39f71a90c94d2cc8a3a2f.camel@j-davis.com>
	<239b7ef6ce058c6b1c77b3a0cfcc70c1cd8968b1.camel@j-davis.com>
	<f1935bc481438c9d86c2e0ac537b1c110d41a00a.camel@j-davis.com>
	<cfd9eb85-c52a-4ec9-a90e-a5e4de56e57d@eisentraut.org>
	<56af65bde2190cc5ee20c807be7b7bdcda54f40c.camel@j-davis.com>
	<468dd1fb-20f5-4213-bc70-d1388ccf28fa@proxel.se>
	<59ea4275d75829a055fc55d8fe139eb85764cf2b.camel@j-davis.com>
	<ece40520-ca74-4b22-8463-f48215854511@proxel.se>
	<de1f1788-93bb-45cc-bef8-6f27119b2f3e@eisentraut.org>
	<89475ee5487d795124f4e25118ea8f1853edb8cb.camel@j-davis.com>

On Tue, 2024-07-30 at 12:13 -0700, Jeff Davis wrote:
> I found a couple issues with the later patches:
> 
> * There was still some confusion about the default collation vs.
> datcollate/datctype for callers of wchar2char() and char2wchar()
> (those
> functions only work for libc). I introduced a new pg_locale_t
> structure
> to represent datcollate/datctype regardless of datlocprovider to
> solve
> this.

I didn't quite like the API I introduced in 0001, so I skipped 0001.

For 0002 I left char2wchar() and wchar2char() as-is, where they expect
libc and accept a NULL pg_locale_t. I committed the rest of 0002.

> * Another loose end relying on setlocale(): in selfuncs.c, there's
> still a call directly to strxfrm(), which depends on setlocale(). I
> changed this to lookup the collation and then use pg_strxfrm(). That
> should improve histogram selectivity estimates because it uses the
> correct provider, rather than relying on setlocale(), right?

Committed 0003.

With these changes, collations are no longer dependent on the
environment locale (setlocale()) at all for either collation behavior
(ORDER BY) or ctype behavior (LOWER(), etc.).

Additionally, unless I missed something, nothing in the server is
dependent on LC_COLLATE at all.

There are still some things that depend on setlocale() in one way or
another:

  - char2wchar() & wchar2char()
  - ts_locale.c
  - various places that depend on LC_CTYPE unrelated to the collation
infrastructure
  - things that depend on other locale settings, like LC_NUMERIC

We can address those as part of a separate thread. I'll count this as
committed.

Regards,
	Jeff Davis






view thread (33+ messages)  latest in thread

Message-ID: <23cc1f3cfcdbdd3b2d3bb956d57ae422aa9d0b9e.camel@j-davis.com>
Permalink:  ../23cc1f3cfcdbdd3b2d3bb956d57ae422aa9d0b9e.camel@j-davis.com/
Also on:    postgresql.org/message-id/23cc1f3cfcdbdd3b2d3bb956d57ae422aa9d0b9e.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: pgsql@j-davis.com, peter@eisentraut.org, andreas@proxel.se
  Subject: Re: tiny step toward threading: reduce dependence on setlocale()
  In-Reply-To: <23cc1f3cfcdbdd3b2d3bb956d57ae422aa9d0b9e.camel@j-davis.com>
  References: <2228884bb1f1a02614b39f71a90c94d2cc8a3a2f.camel@j-davis.com> <239b7ef6ce058c6b1c77b3a0cfcc70c1cd8968b1.camel@j-davis.com> <f1935bc481438c9d86c2e0ac537b1c110d41a00a.camel@j-davis.com> <cfd9eb85-c52a-4ec9-a90e-a5e4de56e57d@eisentraut.org> <56af65bde2190cc5ee20c807be7b7bdcda54f40c.camel@j-davis.com> <468dd1fb-20f5-4213-bc70-d1388ccf28fa@proxel.se> <59ea4275d75829a055fc55d8fe139eb85764cf2b.camel@j-davis.com> <ece40520-ca74-4b22-8463-f48215854511@proxel.se> <de1f1788-93bb-45cc-bef8-6f27119b2f3e@eisentraut.org> <89475ee5487d795124f4e25118ea8f1853edb8cb.camel@j-davis.com> <23cc1f3cfcdbdd3b2d3bb956d57ae422aa9d0b9e.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