summaryrefslogtreecommitdiff
path: root/src/backend/regex
diff options
context:
space:
mode:
authorJeff Davis2024-09-06 20:23:21 +0000
committerJeff Davis2024-09-06 20:23:21 +0000
commit51edc4ca54f826cfac012c7306eee479f07a5dc7 (patch)
tree0a3c3a700a4e317cec6231d0e14782928cc19639 /src/backend/regex
parent129a2f6679fd8891384016b6e2cde6cefda22a7d (diff)
Remove lc_ctype_is_c().
Instead always fetch the locale and look at the ctype_is_c field. hba.c relies on regexes working for the C locale without needing catalog access, which worked before due to a special case for C_COLLATION_OID in lc_ctype_is_c(). Move the special case to pg_set_regex_collation() now that lc_ctype_is_c() is gone. Author: Andreas Karlsson Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/regex')
-rw-r--r--src/backend/regex/regc_pg_locale.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/backend/regex/regc_pg_locale.c b/src/backend/regex/regc_pg_locale.c
index 35361c46a60..8f34948ad37 100644
--- a/src/backend/regex/regc_pg_locale.c
+++ b/src/backend/regex/regc_pg_locale.c
@@ -246,9 +246,13 @@ pg_set_regex_collation(Oid collation)
errhint("Use the COLLATE clause to set the collation explicitly.")));
}
- if (lc_ctype_is_c(collation))
+ if (collation == C_COLLATION_OID)
{
- /* C/POSIX collations use this path regardless of database encoding */
+ /*
+ * Some callers expect regexes to work for C_COLLATION_OID before
+ * catalog access is available, so we can't call
+ * pg_newlocale_from_collation().
+ */
strategy = PG_REGEX_STRATEGY_C;
collation = C_COLLATION_OID;
}
@@ -261,7 +265,17 @@ pg_set_regex_collation(Oid collation)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("nondeterministic collations are not supported for regular expressions")));
- if (locale->provider == COLLPROVIDER_BUILTIN)
+ if (locale->ctype_is_c)
+ {
+ /*
+ * C/POSIX collations use this path regardless of database
+ * encoding
+ */
+ strategy = PG_REGEX_STRATEGY_C;
+ locale = 0;
+ collation = C_COLLATION_OID;
+ }
+ else if (locale->provider == COLLPROVIDER_BUILTIN)
{
Assert(GetDatabaseEncoding() == PG_UTF8);
strategy = PG_REGEX_STRATEGY_BUILTIN;
@@ -274,6 +288,7 @@ pg_set_regex_collation(Oid collation)
#endif
else
{
+ Assert(locale->provider == COLLPROVIDER_LIBC);
if (GetDatabaseEncoding() == PG_UTF8)
strategy = PG_REGEX_STRATEGY_LIBC_WIDE;
else