simplify regular expression locale global variables

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-10-15T06:12:25Z
Lists: pgsql-hackers

Attachments

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.)

Commits

  1. Remove pg_regex_collation