Remove ts_locale.c's lowerstr()
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 17 Dec 2024 13:04:55 +0000 (14:04 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 17 Dec 2024 13:04:55 +0000 (14:04 +0100)
commitfb1a18810f07fc3b722392103d67ce8ed188b63d
treeea418d1a2e82d3104644f550c6a71366f3acfa6c
parentd3aad4ac57c5592ade77916404e6d8a989a1d6a1
Remove ts_locale.c's lowerstr()

lowerstr() and lowerstr_with_len() in ts_locale.c do the same thing as
str_tolower() that the rest of the system uses, except that the former
don't use the common locale provider framework but instead use the
global libc locale settings.

This patch replaces uses of lowerstr*() with str_tolower(...,
DEFAULT_COLLATION_OID).  For instances that use a libc locale
globally, this will result in exactly the same behavior.  For
instances that use other locale providers, you now get consistent
behavior and are no longer dependent on the libc locale settings (for
this case; there are others).

Most uses of these functions are for processing dictionary and
configuration files.  In those cases, using the default collation
seems appropriate.  At least we don't have a more specific collation
available.  But the code in contrib/pg_trgm should really depend on
the collation of the columns being processed.  This is not done here,
this can be done in a separate patch.

(You can probably construct some edge cases where this change would
create some locale-related upgrade incompatibility, for example if
before you used a combination of ICU and a differently-behaving libc
locale.  We can document this in the release notes, but I don't think
there is anything more we can do about this.)

Reviewed-by: Jeff Davis <pgsql@j-davis.com>
Discussion: https://www.postgresql.org/message-id/flat/653f3b84-fc87-45a7-9a0c-bfb4fcab3e7d%40eisentraut.org
12 files changed:
contrib/dict_xsyn/dict_xsyn.c
contrib/pg_trgm/trgm_op.c
contrib/pg_trgm/trgm_regexp.c
src/backend/snowball/dict_snowball.c
src/backend/tsearch/dict_ispell.c
src/backend/tsearch/dict_simple.c
src/backend/tsearch/dict_synonym.c
src/backend/tsearch/spell.c
src/backend/tsearch/ts_locale.c
src/backend/tsearch/ts_utils.c
src/include/tsearch/ts_locale.h
src/include/tsearch/ts_public.h