Re: simplify regular expression locale global variables

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: simplify regular expression locale global variables
Date: 2024-10-15 10:08:01
Message-ID: 202410151008.jnqrposiz6p5@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2024-Oct-15, Peter Eisentraut wrote:

> @@ -253,8 +241,9 @@ pg_set_regex_collation(Oid collation)
> * catalog access is available, so we can't call
> * pg_newlocale_from_collation().
> */
> + static struct pg_locale_struct dummy_locale = {.ctype_is_c = true};
> +
> + locale = &dummy_locale;
> }
> else
> {
> @@ -264,121 +253,80 @@ pg_set_regex_collation(Oid collation)
> ereport(ERROR,
> (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
> errmsg("nondeterministic collations are not supported for regular expressions")));
> [...]
> }
>
> pg_regex_locale = locale;
> }

Hmm, is it valid to make pg_regex_locale point to a function-local
static here? The lifetime of this static is not clear to me, and I
think this pattern works with at least some compilers, but I remember
comments on previous patch review threads that this pattern isn't
kosher.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2024-10-15 10:41:20 Re: Add support to TLS 1.3 cipher suites and curves lists
Previous Message jian he 2024-10-15 09:50:15 Re: type cache cleanup improvements