aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/formatting.c
diff options
context:
space:
mode:
authorJeff Davis <jdavis@postgresql.org>2024-09-06 13:23:21 -0700
committerJeff Davis <jdavis@postgresql.org>2024-09-06 13:23:21 -0700
commit51edc4ca54f826cfac012c7306eee479f07a5dc7 (patch)
tree0a3c3a700a4e317cec6231d0e14782928cc19639 /src/backend/utils/adt/formatting.c
parent129a2f6679fd8891384016b6e2cde6cefda22a7d (diff)
downloadpostgresql-51edc4ca54f826cfac012c7306eee479f07a5dc7.tar.gz
postgresql-51edc4ca54f826cfac012c7306eee479f07a5dc7.zip
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/60929555-4709-40a7-b136-bcb44cff5a3c@proxel.se
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r--src/backend/utils/adt/formatting.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 33a810b008d..68fa89418ff 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1636,6 +1636,7 @@ char *
str_tolower(const char *buff, size_t nbytes, Oid collid)
{
char *result;
+ pg_locale_t mylocale;
if (!buff)
return NULL;
@@ -1653,17 +1654,15 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
errhint("Use the COLLATE clause to set the collation explicitly.")));
}
+ mylocale = pg_newlocale_from_collation(collid);
+
/* C/POSIX collations use this path regardless of database encoding */
- if (lc_ctype_is_c(collid))
+ if (mylocale->ctype_is_c)
{
result = asc_tolower(buff, nbytes);
}
else
{
- pg_locale_t mylocale;
-
- mylocale = pg_newlocale_from_collation(collid);
-
#ifdef USE_ICU
if (mylocale->provider == COLLPROVIDER_ICU)
{
@@ -1774,6 +1773,7 @@ char *
str_toupper(const char *buff, size_t nbytes, Oid collid)
{
char *result;
+ pg_locale_t mylocale;
if (!buff)
return NULL;
@@ -1791,17 +1791,15 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
errhint("Use the COLLATE clause to set the collation explicitly.")));
}
+ mylocale = pg_newlocale_from_collation(collid);
+
/* C/POSIX collations use this path regardless of database encoding */
- if (lc_ctype_is_c(collid))
+ if (mylocale->ctype_is_c)
{
result = asc_toupper(buff, nbytes);
}
else
{
- pg_locale_t mylocale;
-
- mylocale = pg_newlocale_from_collation(collid);
-
#ifdef USE_ICU
if (mylocale->provider == COLLPROVIDER_ICU)
{
@@ -1954,6 +1952,7 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
{
char *result;
int wasalnum = false;
+ pg_locale_t mylocale;
if (!buff)
return NULL;
@@ -1971,17 +1970,15 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
errhint("Use the COLLATE clause to set the collation explicitly.")));
}
+ mylocale = pg_newlocale_from_collation(collid);
+
/* C/POSIX collations use this path regardless of database encoding */
- if (lc_ctype_is_c(collid))
+ if (mylocale->ctype_is_c)
{
result = asc_initcap(buff, nbytes);
}
else
{
- pg_locale_t mylocale;
-
- mylocale = pg_newlocale_from_collation(collid);
-
#ifdef USE_ICU
if (mylocale->provider == COLLPROVIDER_ICU)
{