diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2024-09-13 16:10:52 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2024-09-13 16:10:52 +0200 |
commit | 433d8f40e957c042d7d224e4561ca033252baf37 (patch) | |
tree | 6342e549c32c255e6d938ef330353a5446c422a7 /src/backend/utils/adt/like_match.c | |
parent | 2b67bdca529c6aed4303eb6963d09d1b540137b8 (diff) | |
download | postgresql-433d8f40e957c042d7d224e4561ca033252baf37.tar.gz postgresql-433d8f40e957c042d7d224e4561ca033252baf37.zip |
Remove separate locale_is_c arguments
Since e9931bfb751, ctype_is_c is part of pg_locale_t. Some functions
passed a pg_locale_t and a bool argument separately. This can now be
combined into one argument.
Since some callers call MatchText() with locale 0, it is a bit
confusing whether this is all correct. But it is the case that only
callers that pass a non-zero locale object to MatchText() end up
checking locale->ctype_is_c. To make that flow a bit more
understandable, add the locale argument to MATCH_LOWER() and GETCHAR()
in like_match.c, instead of implicitly taking it from the outer scope.
Reviewed-by: Jeff Davis <pgsql@j-davis.com>
Discussion: https://www.postgresql.org/message-id/84d415fc-6780-419e-b16c-61a0ca819e2b@eisentraut.org
Diffstat (limited to 'src/backend/utils/adt/like_match.c')
-rw-r--r-- | src/backend/utils/adt/like_match.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c index f2990edff7e..f561cc15e4c 100644 --- a/src/backend/utils/adt/like_match.c +++ b/src/backend/utils/adt/like_match.c @@ -71,14 +71,13 @@ */ #ifdef MATCH_LOWER -#define GETCHAR(t) MATCH_LOWER(t) +#define GETCHAR(t, locale) MATCH_LOWER(t, locale) #else -#define GETCHAR(t) (t) +#define GETCHAR(t, locale) (t) #endif static int -MatchText(const char *t, int tlen, const char *p, int plen, - pg_locale_t locale, bool locale_is_c) +MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale) { /* Fast path for match-everything pattern */ if (plen == 1 && *p == '%') @@ -106,7 +105,7 @@ MatchText(const char *t, int tlen, const char *p, int plen, ereport(ERROR, (errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE), errmsg("LIKE pattern must not end with escape character"))); - if (GETCHAR(*p) != GETCHAR(*t)) + if (GETCHAR(*p, locale) != GETCHAR(*t, locale)) return LIKE_FALSE; } else if (*p == '%') @@ -166,17 +165,16 @@ MatchText(const char *t, int tlen, const char *p, int plen, ereport(ERROR, (errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE), errmsg("LIKE pattern must not end with escape character"))); - firstpat = GETCHAR(p[1]); + firstpat = GETCHAR(p[1], locale); } else - firstpat = GETCHAR(*p); + firstpat = GETCHAR(*p, locale); while (tlen > 0) { - if (GETCHAR(*t) == firstpat) + if (GETCHAR(*t, locale) == firstpat) { - int matched = MatchText(t, tlen, p, plen, - locale, locale_is_c); + int matched = MatchText(t, tlen, p, plen, locale); if (matched != LIKE_FALSE) return matched; /* TRUE or ABORT */ @@ -198,7 +196,7 @@ MatchText(const char *t, int tlen, const char *p, int plen, NextByte(p, plen); continue; } - else if (GETCHAR(*p) != GETCHAR(*t)) + else if (GETCHAR(*p, locale) != GETCHAR(*t, locale)) { /* non-wildcard pattern char fails to match text char */ return LIKE_FALSE; |