simplify regular expression locale global variables

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: simplify regular expression locale global variables
Date: 2024-10-15 06:12:25
Message-ID: b1b92ae1-2e06-4619-a87a-4b4858e547ec@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

We currently have

static PG_Locale_Strategy pg_regex_strategy;
static pg_locale_t pg_regex_locale;
static Oid pg_regex_collation;

but after the recent improvements to pg_locale_t handling, we don't need
all three anymore. All the information we have is contained in
pg_locale_t, so we just need to keep that one. This allows us to
structure the locale-using regular expression code more similar to other
locale-using code, mainly by provider, avoiding another layer that is
specific only to the regular expression code. The first patch
implements that.

The second patch removes a call to pg_set_regex_collation() that I think
is unnecessary.

The third patch adds a pg_unset_regex_collation() call that undoes what
pg_set_regex_collation() does. I mainly used this to verify the second
patch, but maybe it's also useful on its own, not sure.

(I don't have any plans to get rid of the remaining global variable.
That would certainly be nice from an intellectual point of view, but
fiddling this into the regular expression code looks quite messy. In
any case, it's probably easier with one variable instead of three, if
someone wants to try.)

Attachment Content-Type Size
0001-Remove-pg_regex_collation-and-pg_regex_strategy.patch text/plain 19.3 KB
0002-Remove-unneeded-pg_set_regex_collation-call.patch text/plain 972 bytes
0003-WIP-Add-pg_unset_regex_collation.patch text/plain 4.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2024-10-15 06:20:49 Re: Consider the number of columns in the sort cost model
Previous Message David Rowley 2024-10-15 05:15:13 Re: Consider the number of columns in the sort cost model