diff options
| author | Jeff Davis | 2023-03-17 18:47:35 +0000 |
|---|---|---|
| committer | Jeff Davis | 2023-03-17 19:08:46 +0000 |
| commit | f413941f41d370a7893caa3e6ed384b89a0577fd (patch) | |
| tree | 05a69d2b5ddd453939f3a5346c525fc51ec304ba /src/backend/tsearch | |
| parent | 064709f803c05559d2849a62fdb855fbb91ffeb8 (diff) | |
Fix t_isspace(), etc., when datlocprovider=i and datctype=C.
Check whether the datctype is C to determine whether t_isspace() and
related functions use isspace() or iswspace().
Previously, t_isspace() checked whether the database default collation
was C; which is incorrect when the default collation uses the ICU
provider.
Discussion: https://postgr.es/m/[email protected]
Reviewed-by: Peter Eisentraut
Backpatch-through: 15
Diffstat (limited to 'src/backend/tsearch')
| -rw-r--r-- | src/backend/tsearch/ts_locale.c | 18 | ||||
| -rw-r--r-- | src/backend/tsearch/wparser_def.c | 3 |
2 files changed, 7 insertions, 14 deletions
diff --git a/src/backend/tsearch/ts_locale.c b/src/backend/tsearch/ts_locale.c index 0c031709902..f1150d30b71 100644 --- a/src/backend/tsearch/ts_locale.c +++ b/src/backend/tsearch/ts_locale.c @@ -38,10 +38,9 @@ t_isdigit(const char *ptr) { int clen = pg_mblen(ptr); wchar_t character[WC_BUF_LEN]; - Oid collation = DEFAULT_COLLATION_OID; /* TODO */ pg_locale_t mylocale = 0; /* TODO */ - if (clen == 1 || lc_ctype_is_c(collation)) + if (clen == 1 || database_ctype_is_c) return isdigit(TOUCHAR(ptr)); char2wchar(character, WC_BUF_LEN, ptr, clen, mylocale); @@ -54,10 +53,9 @@ t_isspace(const char *ptr) { int clen = pg_mblen(ptr); wchar_t character[WC_BUF_LEN]; - Oid collation = DEFAULT_COLLATION_OID; /* TODO */ pg_locale_t mylocale = 0; /* TODO */ - if (clen == 1 || lc_ctype_is_c(collation)) + if (clen == 1 || database_ctype_is_c) return isspace(TOUCHAR(ptr)); char2wchar(character, WC_BUF_LEN, ptr, clen, mylocale); @@ -70,10 +68,9 @@ t_isalpha(const char *ptr) { int clen = pg_mblen(ptr); wchar_t character[WC_BUF_LEN]; - Oid collation = DEFAULT_COLLATION_OID; /* TODO */ pg_locale_t mylocale = 0; /* TODO */ - if (clen == 1 || lc_ctype_is_c(collation)) + if (clen == 1 || database_ctype_is_c) return isalpha(TOUCHAR(ptr)); char2wchar(character, WC_BUF_LEN, ptr, clen, mylocale); @@ -86,10 +83,9 @@ t_isalnum(const char *ptr) { int clen = pg_mblen(ptr); wchar_t character[WC_BUF_LEN]; - Oid collation = DEFAULT_COLLATION_OID; /* TODO */ pg_locale_t mylocale = 0; /* TODO */ - if (clen == 1 || lc_ctype_is_c(collation)) + if (clen == 1 || database_ctype_is_c) return isalnum(TOUCHAR(ptr)); char2wchar(character, WC_BUF_LEN, ptr, clen, mylocale); @@ -102,10 +98,9 @@ t_isprint(const char *ptr) { int clen = pg_mblen(ptr); wchar_t character[WC_BUF_LEN]; - Oid collation = DEFAULT_COLLATION_OID; /* TODO */ pg_locale_t mylocale = 0; /* TODO */ - if (clen == 1 || lc_ctype_is_c(collation)) + if (clen == 1 || database_ctype_is_c) return isprint(TOUCHAR(ptr)); char2wchar(character, WC_BUF_LEN, ptr, clen, mylocale); @@ -273,7 +268,6 @@ char * lowerstr_with_len(const char *str, int len) { char *out; - Oid collation = DEFAULT_COLLATION_OID; /* TODO */ pg_locale_t mylocale = 0; /* TODO */ if (len == 0) @@ -285,7 +279,7 @@ lowerstr_with_len(const char *str, int len) * Also, for a C locale there is no need to process as multibyte. From * backend/utils/adt/oracle_compat.c Teodor */ - if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c(collation)) + if (pg_database_encoding_max_length() > 1 && !database_ctype_is_c) { wchar_t *wstr, *wptr; diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c index cc3736454ec..840a44ec007 100644 --- a/src/backend/tsearch/wparser_def.c +++ b/src/backend/tsearch/wparser_def.c @@ -297,11 +297,10 @@ TParserInit(char *str, int len) */ if (prs->charmaxlen > 1) { - Oid collation = DEFAULT_COLLATION_OID; /* TODO */ pg_locale_t mylocale = 0; /* TODO */ prs->usewide = true; - if (lc_ctype_is_c(collation)) + if (database_ctype_is_c) { /* * char2wchar doesn't work for C-locale and sizeof(pg_wchar) could |
