1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-25 20:23:07 +03:00

Remove support for null pg_locale_t most places.

Previously, passing NULL for pg_locale_t meant "use the libc provider
and the server environment". Now that the database collation is
represented as a proper pg_locale_t (not dependent on setlocale()),
remove special cases for NULL.

Leave wchar2char() and char2wchar() unchanged for now, because the
callers don't always have a libc-based pg_locale_t available.

Discussion: https://postgr.es/m/cfd9eb85-c52a-4ec9-a90e-a5e4de56e57d@eisentraut.org
Reviewed-by: Peter Eisentraut, Andreas Karlsson
This commit is contained in:
Jeff Davis
2024-08-05 18:15:57 -07:00
parent f80b09bac8
commit e9931bfb75
7 changed files with 73 additions and 255 deletions

View File

@@ -174,8 +174,7 @@ Generic_Text_IC_like(text *str, text *pat, Oid collation)
*p;
int slen,
plen;
pg_locale_t locale = 0;
bool locale_is_c = false;
pg_locale_t locale;
if (!OidIsValid(collation))
{
@@ -189,10 +188,7 @@ Generic_Text_IC_like(text *str, text *pat, Oid collation)
errhint("Use the COLLATE clause to set the collation explicitly.")));
}
if (lc_ctype_is_c(collation))
locale_is_c = true;
else
locale = pg_newlocale_from_collation(collation);
locale = pg_newlocale_from_collation(collation);
if (!pg_locale_deterministic(locale))
ereport(ERROR,
@@ -228,7 +224,7 @@ Generic_Text_IC_like(text *str, text *pat, Oid collation)
plen = VARSIZE_ANY_EXHDR(pat);
s = VARDATA_ANY(str);
slen = VARSIZE_ANY_EXHDR(str);
return SB_IMatchText(s, slen, p, plen, locale, locale_is_c);
return SB_IMatchText(s, slen, p, plen, locale, locale->ctype_is_c);
}
}