aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/like_match.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-04-09 17:12:39 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-04-09 17:12:39 -0400
commit00f11f419caa873b44d70071d4ade0b8c75e7f36 (patch)
treee40852e2cb1310802d47c5b4eab003e775e9ed99 /src/backend/utils/adt/like_match.c
parentf89e4dfa755b9c9be9c19f7c65cff50d47b4f33a (diff)
downloadpostgresql-00f11f419caa873b44d70071d4ade0b8c75e7f36.tar.gz
postgresql-00f11f419caa873b44d70071d4ade0b8c75e7f36.zip
Fix ILIKE to honor collation when working in single-byte encodings.
The original collation patch only fixed the multi-byte code path. This change also ensures that ILIKE's idea of the case-folding rules is exactly the same as str_tolower's.
Diffstat (limited to 'src/backend/utils/adt/like_match.c')
-rw-r--r--src/backend/utils/adt/like_match.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c
index 2a99e940170..214664116d7 100644
--- a/src/backend/utils/adt/like_match.c
+++ b/src/backend/utils/adt/like_match.c
@@ -5,7 +5,7 @@
*
* This file is included by like.c four times, to provide matching code for
* (1) single-byte encodings, (2) UTF8, (3) other multi-byte encodings,
- * and (4) case insensitive matches in single byte encodings.
+ * and (4) case insensitive matches in single-byte encodings.
* (UTF8 is a special case because we can use a much more efficient version
* of NextChar than can be used for general multi-byte encodings.)
*
@@ -14,7 +14,7 @@
* NextChar
* MatchText - to name of function wanted
* do_like_escape - name of function if wanted - needs CHAREQ and CopyAdvChar
- * MATCH_LOWER - define for case (4), using to_lower on single-byte chars
+ * MATCH_LOWER - define for case (4) to specify case folding for 1-byte chars
*
* Copyright (c) 1996-2011, PostgreSQL Global Development Group
*
@@ -70,13 +70,14 @@
*/
#ifdef MATCH_LOWER
-#define GETCHAR(t) ((char) tolower((unsigned char) (t)))
+#define GETCHAR(t) MATCH_LOWER(t)
#else
#define GETCHAR(t) (t)
#endif
static int
-MatchText(char *t, int tlen, char *p, int plen)
+MatchText(char *t, int tlen, char *p, int plen,
+ pg_locale_t locale, bool locale_is_c)
{
/* Fast path for match-everything pattern */
if (plen == 1 && *p == '%')
@@ -170,7 +171,8 @@ MatchText(char *t, int tlen, char *p, int plen)
{
if (GETCHAR(*t) == firstpat)
{
- int matched = MatchText(t, tlen, p, plen);
+ int matched = MatchText(t, tlen, p, plen,
+ locale, locale_is_c);
if (matched != LIKE_FALSE)
return matched; /* TRUE or ABORT */