Re: tiny step toward threading: reduce dependence on setlocale()

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Jeff Davis <pgsql(at)j-davis(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: tiny step toward threading: reduce dependence on setlocale()
Date: 2024-08-13 23:31:11
Message-ID: 69c2a864-846f-4309-bd5a-aaa1c34f9a11@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 8/13/24 7:56 PM, Jeff Davis wrote:
> But I don't think that's a major problem -- we can just move the
> hardcoded test into pg_newlocale_from_collation() and return a
> predefined struct with collate_is_c/ctype_is_c already set.

I tried that out but thought it felt cleaner to do the hardcoding in
pg_set_regex_collation(). What do you think?

I have attached patches removing lc_collate_is_c() and lc_ctype_is_c().
I have not checked if there are any performance regressions when using
the C and POSIX locales but remove these special cases makes the code a
lot cleaner in my book.

I also attach some other clean up patches I did while touching this code.

0001-Remove-lc_collate_is_c.patch

Removes lc_collate_is_c().

0002-Remove-lc_ctype_is_c.patch

Removes lc_ctype_is_c() and POSIX_COLLATION_OID which is no longer
necessary.

0003-Remove-dubious-check-against-default-locale.patch

This patch removes a check against DEFAULT_COLLATION_OID which I thought
looked really dubious. Shouldn't this just be a simple check for if the
locale is deterministic? Since we know we have a valid locale that
should be enough, right?

0004-Do-not-check-both-for-collate_is_c-and-deterministic.patch

It is redundant to check both for "collation_is_c && deterministic", right?

0005-Remove-pg_collate_deterministic-and-check-field-dire.patch

Since after my patches we look a lot directly at the collation_is_c and
ctype_is_c fields I think the thin wrapper around the deterministic
field makes it seem like there is more to it so I suggest that we should
just remove it.

0006-Slightly-refactor-varstr_sortsupport-to-improve-read.patch

Small refactor to make a hard to read function a bit easier to read.

Andreas

Attachment Content-Type Size
0001-Remove-lc_collate_is_c.patch text/x-patch 9.8 KB
0002-Remove-lc_ctype_is_c.patch text/x-patch 9.9 KB
0003-Remove-dubious-check-against-default-locale.patch text/x-patch 741 bytes
0004-Do-not-check-both-for-collate_is_c-and-deterministic.patch text/x-patch 1.7 KB
0005-Remove-pg_collate_deterministic-and-check-field-dire.patch text/x-patch 7.5 KB
0006-Slightly-refactor-varstr_sortsupport-to-improve-read.patch text/x-patch 2.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-08-14 00:00:00 Re: Virtual generated columns
Previous Message Thomas Munro 2024-08-13 23:27:50 Re: Thread-safe nl_langinfo() and localeconv()