diff options
author | Jeff Davis <jdavis@postgresql.org> | 2025-04-21 12:34:58 -0700 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2025-04-21 12:34:58 -0700 |
commit | 90260e2ec6bbfc3dfa9d9501ab75c535de52f677 (patch) | |
tree | eedee7e0630fc5f52235270186f8a061777e9500 /src/backend/utils/adt/pg_locale_builtin.c | |
parent | 80b727eb9deab589a8648750bc20f1623d5acd3e (diff) | |
download | postgresql-90260e2ec6bbfc3dfa9d9501ab75c535de52f677.tar.gz postgresql-90260e2ec6bbfc3dfa9d9501ab75c535de52f677.zip |
Fix INITCAP() word boundaries for PG_UNICODE_FAST.
Word boundaries are based on whether a character is alphanumeric or
not. For the PG_UNICODE_FAST collation, alphanumeric includes
non-ASCII digits; whereas for the PG_C_UTF8 collation, it only
includes digits 0-9. Pass down the right information from the
pg_locale_t into initcap_wbnext to differentiate the behavior.
Reported-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/20250417135841.33.nmisch@google.com
Diffstat (limited to 'src/backend/utils/adt/pg_locale_builtin.c')
-rw-r--r-- | src/backend/utils/adt/pg_locale_builtin.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/utils/adt/pg_locale_builtin.c b/src/backend/utils/adt/pg_locale_builtin.c index 125b10ff7ab..f51768830cd 100644 --- a/src/backend/utils/adt/pg_locale_builtin.c +++ b/src/backend/utils/adt/pg_locale_builtin.c @@ -40,6 +40,7 @@ struct WordBoundaryState const char *str; size_t len; size_t offset; + bool posix; bool init; bool prev_alnum; }; @@ -58,7 +59,7 @@ initcap_wbnext(void *state) { pg_wchar u = utf8_to_unicode((unsigned char *) wbstate->str + wbstate->offset); - bool curr_alnum = pg_u_isalnum(u, true); + bool curr_alnum = pg_u_isalnum(u, wbstate->posix); if (!wbstate->init || curr_alnum != wbstate->prev_alnum) { @@ -92,6 +93,7 @@ strtitle_builtin(char *dest, size_t destsize, const char *src, ssize_t srclen, .str = src, .len = srclen, .offset = 0, + .posix = !locale->info.builtin.casemap_full, .init = false, .prev_alnum = false, }; |