mirror of
https://github.com/postgres/postgres.git
synced 2025-12-15 02:22:24 +03:00
Remove char_tolower() API.
It's only useful for an ILIKE optimization for the libc provider using a single-byte encoding and a non-C locale, but it creates significant internal complexity. Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Discussion: https://postgr.es/m/450ceb6260cad30d7afdf155d991a9caafee7c0d.camel@j-davis.com
This commit is contained in:
@@ -70,10 +70,14 @@
|
||||
*--------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* MATCH_LOWER is defined for ILIKE in the C locale as an optimization. Other
|
||||
* locales must casefold the inputs before matching.
|
||||
*/
|
||||
#ifdef MATCH_LOWER
|
||||
#define GETCHAR(t, locale) MATCH_LOWER(t, locale)
|
||||
#define GETCHAR(t) pg_ascii_tolower(t)
|
||||
#else
|
||||
#define GETCHAR(t, locale) (t)
|
||||
#define GETCHAR(t) (t)
|
||||
#endif
|
||||
|
||||
static int
|
||||
@@ -105,7 +109,7 @@ MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
|
||||
errmsg("LIKE pattern must not end with escape character")));
|
||||
if (GETCHAR(*p, locale) != GETCHAR(*t, locale))
|
||||
if (GETCHAR(*p) != GETCHAR(*t))
|
||||
return LIKE_FALSE;
|
||||
}
|
||||
else if (*p == '%')
|
||||
@@ -167,14 +171,14 @@ MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
|
||||
errmsg("LIKE pattern must not end with escape character")));
|
||||
firstpat = GETCHAR(p[1], locale);
|
||||
firstpat = GETCHAR(p[1]);
|
||||
}
|
||||
else
|
||||
firstpat = GETCHAR(*p, locale);
|
||||
firstpat = GETCHAR(*p);
|
||||
|
||||
while (tlen > 0)
|
||||
{
|
||||
if (GETCHAR(*t, locale) == firstpat || (locale && !locale->deterministic))
|
||||
if (GETCHAR(*t) == firstpat || (locale && !locale->deterministic))
|
||||
{
|
||||
int matched = MatchText(t, tlen, p, plen, locale);
|
||||
|
||||
@@ -342,7 +346,7 @@ MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale)
|
||||
NextChar(t1, t1len);
|
||||
}
|
||||
}
|
||||
else if (GETCHAR(*p, locale) != GETCHAR(*t, locale))
|
||||
else if (GETCHAR(*p) != GETCHAR(*t))
|
||||
{
|
||||
/* non-wildcard pattern char fails to match text char */
|
||||
return LIKE_FALSE;
|
||||
|
||||
Reference in New Issue
Block a user