PostgreSQL Source Code  git master
like.c File Reference
#include "postgres.h"
#include <ctype.h>
#include "catalog/pg_collation.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/pg_locale.h"
#include "like_match.c"
Include dependency graph for like.c:

Go to the source code of this file.

Macros

#define LIKE_TRUE   1
 
#define LIKE_FALSE   0
 
#define LIKE_ABORT   (-1)
 
#define NextByte(p, plen)   ((p)++, (plen)--)
 
#define CHAREQ(p1, p2)   wchareq((p1), (p2))
 
#define NextChar(p, plen)    do { int __l = pg_mblen(p); (p) +=__l; (plen) -=__l; } while (0)
 
#define CopyAdvChar(dst, src, srclen)
 
#define MatchText   MB_MatchText
 
#define do_like_escape   MB_do_like_escape
 
#define CHAREQ(p1, p2)   (*(p1) == *(p2))
 
#define NextChar(p, plen)   NextByte((p), (plen))
 
#define CopyAdvChar(dst, src, srclen)   (*(dst)++ = *(src)++, (srclen)--)
 
#define MatchText   SB_MatchText
 
#define do_like_escape   SB_do_like_escape
 
#define MATCH_LOWER(t)   SB_lower_char((unsigned char) (t), locale, locale_is_c)
 
#define NextChar(p, plen)   NextByte((p), (plen))
 
#define MatchText   SB_IMatchText
 
#define NextChar(p, plen)    do { (p)++; (plen)--; } while ((plen) > 0 && (*(p) & 0xC0) == 0x80 )
 
#define MatchText   UTF8_MatchText
 

Functions

static int SB_MatchText (const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
 
static textSB_do_like_escape (text *, text *)
 
static int MB_MatchText (const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
 
static textMB_do_like_escape (text *, text *)
 
static int UTF8_MatchText (const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
 
static int SB_IMatchText (const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
 
static int GenericMatchText (const char *s, int slen, const char *p, int plen, Oid collation)
 
static int Generic_Text_IC_like (text *str, text *pat, Oid collation)
 
static int wchareq (const char *p1, const char *p2)
 
static char SB_lower_char (unsigned char c, pg_locale_t locale, bool locale_is_c)
 
Datum namelike (PG_FUNCTION_ARGS)
 
Datum namenlike (PG_FUNCTION_ARGS)
 
Datum textlike (PG_FUNCTION_ARGS)
 
Datum textnlike (PG_FUNCTION_ARGS)
 
Datum bytealike (PG_FUNCTION_ARGS)
 
Datum byteanlike (PG_FUNCTION_ARGS)
 
Datum nameiclike (PG_FUNCTION_ARGS)
 
Datum nameicnlike (PG_FUNCTION_ARGS)
 
Datum texticlike (PG_FUNCTION_ARGS)
 
Datum texticnlike (PG_FUNCTION_ARGS)
 
Datum like_escape (PG_FUNCTION_ARGS)
 
Datum like_escape_bytea (PG_FUNCTION_ARGS)
 

Macro Definition Documentation

◆ CHAREQ [1/2]

#define CHAREQ (   p1,
  p2 
)    wchareq((p1), (p2))

Definition at line 125 of file like.c.

◆ CHAREQ [2/2]

#define CHAREQ (   p1,
  p2 
)    (*(p1) == *(p2))

Definition at line 125 of file like.c.

◆ CopyAdvChar [1/2]

#define CopyAdvChar (   dst,
  src,
  srclen 
)
Value:
do { int __l = pg_mblen(src); \
(srclen) -= __l; \
while (__l-- > 0) \
*(dst)++ = *(src)++; \
} while (0)
int pg_mblen(const char *mbstr)
Definition: mbutils.c:966

Definition at line 127 of file like.c.

◆ CopyAdvChar [2/2]

#define CopyAdvChar (   dst,
  src,
  srclen 
)    (*(dst)++ = *(src)++, (srclen)--)

Definition at line 127 of file like.c.

◆ do_like_escape [1/2]

#define do_like_escape   MB_do_like_escape

Definition at line 130 of file like.c.

◆ do_like_escape [2/2]

#define do_like_escape   SB_do_like_escape

Definition at line 130 of file like.c.

◆ LIKE_ABORT

#define LIKE_ABORT   (-1)

Definition at line 31 of file like.c.

◆ LIKE_FALSE

#define LIKE_FALSE   0

Definition at line 30 of file like.c.

◆ LIKE_TRUE

#define LIKE_TRUE   1

Definition at line 29 of file like.c.

◆ MATCH_LOWER

#define MATCH_LOWER (   t)    SB_lower_char((unsigned char) (t), locale, locale_is_c)

Definition at line 135 of file like.c.

◆ MatchText [1/4]

#define MatchText   MB_MatchText

Definition at line 145 of file like.c.

◆ MatchText [2/4]

#define MatchText   SB_MatchText

Definition at line 145 of file like.c.

◆ MatchText [3/4]

#define MatchText   SB_IMatchText

Definition at line 145 of file like.c.

◆ MatchText [4/4]

#define MatchText   UTF8_MatchText

Definition at line 145 of file like.c.

◆ NextByte

#define NextByte (   p,
  plen 
)    ((p)++, (plen)--)

Definition at line 106 of file like.c.

◆ NextChar [1/4]

#define NextChar (   p,
  plen 
)     do { int __l = pg_mblen(p); (p) +=__l; (plen) -=__l; } while (0)

Definition at line 143 of file like.c.

◆ NextChar [2/4]

#define NextChar (   p,
  plen 
)    NextByte((p), (plen))

Definition at line 143 of file like.c.

◆ NextChar [3/4]

#define NextChar (   p,
  plen 
)    NextByte((p), (plen))

Definition at line 143 of file like.c.

◆ NextChar [4/4]

#define NextChar (   p,
  plen 
)     do { (p)++; (plen)--; } while ((plen) > 0 && (*(p) & 0xC0) == 0x80 )

Definition at line 143 of file like.c.

Function Documentation

◆ bytealike()

Datum bytealike ( PG_FUNCTION_ARGS  )

Definition at line 325 of file like.c.

326 {
328  bytea *pat = PG_GETARG_BYTEA_PP(1);
329  bool result;
330  char *s,
331  *p;
332  int slen,
333  plen;
334 
335  s = VARDATA_ANY(str);
336  slen = VARSIZE_ANY_EXHDR(str);
337  p = VARDATA_ANY(pat);
338  plen = VARSIZE_ANY_EXHDR(pat);
339 
340  result = (SB_MatchText(s, slen, p, plen, 0, true) == LIKE_TRUE);
341 
342  PG_RETURN_BOOL(result);
343 }
#define PG_GETARG_BYTEA_PP(n)
Definition: fmgr.h:308
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
static int SB_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
#define LIKE_TRUE
Definition: like.c:29
#define VARDATA_ANY(PTR)
Definition: postgres.h:361
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:354
Definition: c.h:633

References LIKE_TRUE, PG_GETARG_BYTEA_PP, PG_RETURN_BOOL, SB_MatchText(), generate_unaccent_rules::str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ byteanlike()

Datum byteanlike ( PG_FUNCTION_ARGS  )

Definition at line 346 of file like.c.

347 {
349  bytea *pat = PG_GETARG_BYTEA_PP(1);
350  bool result;
351  char *s,
352  *p;
353  int slen,
354  plen;
355 
356  s = VARDATA_ANY(str);
357  slen = VARSIZE_ANY_EXHDR(str);
358  p = VARDATA_ANY(pat);
359  plen = VARSIZE_ANY_EXHDR(pat);
360 
361  result = (SB_MatchText(s, slen, p, plen, 0, true) != LIKE_TRUE);
362 
363  PG_RETURN_BOOL(result);
364 }

References LIKE_TRUE, PG_GETARG_BYTEA_PP, PG_RETURN_BOOL, SB_MatchText(), generate_unaccent_rules::str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ Generic_Text_IC_like()

static int Generic_Text_IC_like ( text str,
text pat,
Oid  collation 
)
inlinestatic

Definition at line 172 of file like.c.

173 {
174  char *s,
175  *p;
176  int slen,
177  plen;
178  pg_locale_t locale = 0;
179  bool locale_is_c = false;
180 
181  if (!OidIsValid(collation))
182  {
183  /*
184  * This typically means that the parser could not resolve a conflict
185  * of implicit collations, so report it that way.
186  */
187  ereport(ERROR,
188  (errcode(ERRCODE_INDETERMINATE_COLLATION),
189  errmsg("could not determine which collation to use for ILIKE"),
190  errhint("Use the COLLATE clause to set the collation explicitly.")));
191  }
192 
193  if (lc_ctype_is_c(collation))
194  locale_is_c = true;
195  else
196  locale = pg_newlocale_from_collation(collation);
197 
198  if (locale && !locale->deterministic)
199  ereport(ERROR,
200  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
201  errmsg("nondeterministic collations are not supported for ILIKE")));
202 
203  /*
204  * For efficiency reasons, in the single byte case we don't call lower()
205  * on the pattern and text, but instead call SB_lower_char on each
206  * character. In the multi-byte case we don't have much choice :-(. Also,
207  * ICU does not support single-character case folding, so we go the long
208  * way.
209  */
210 
211  if (pg_database_encoding_max_length() > 1 || (locale && locale->provider == COLLPROVIDER_ICU))
212  {
214  PointerGetDatum(pat)));
215  p = VARDATA_ANY(pat);
216  plen = VARSIZE_ANY_EXHDR(pat);
218  PointerGetDatum(str)));
219  s = VARDATA_ANY(str);
220  slen = VARSIZE_ANY_EXHDR(str);
221  if (GetDatabaseEncoding() == PG_UTF8)
222  return UTF8_MatchText(s, slen, p, plen, 0, true);
223  else
224  return MB_MatchText(s, slen, p, plen, 0, true);
225  }
226  else
227  {
228  p = VARDATA_ANY(pat);
229  plen = VARSIZE_ANY_EXHDR(pat);
230  s = VARDATA_ANY(str);
231  slen = VARSIZE_ANY_EXHDR(str);
232  return SB_IMatchText(s, slen, p, plen, locale, locale_is_c);
233  }
234 }
#define OidIsValid(objectId)
Definition: c.h:721
int errhint(const char *fmt,...)
Definition: elog.c:1151
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define ERROR
Definition: elog.h:33
#define ereport(elevel,...)
Definition: elog.h:143
Datum DirectFunctionCall1Coll(PGFunction func, Oid collation, Datum arg1)
Definition: fmgr.c:777
#define DatumGetTextPP(X)
Definition: fmgr.h:292
static char * locale
Definition: initdb.c:128
static int UTF8_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
static int SB_IMatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
static int MB_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
int GetDatabaseEncoding(void)
Definition: mbutils.c:1210
int pg_database_encoding_max_length(void)
Definition: mbutils.c:1495
Datum lower(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:48
pg_locale_t pg_newlocale_from_collation(Oid collid)
Definition: pg_locale.c:1508
bool lc_ctype_is_c(Oid collation)
Definition: pg_locale.c:1379
@ PG_UTF8
Definition: pg_wchar.h:230
#define PointerGetDatum(X)
Definition: postgres.h:600

References DatumGetTextPP, DirectFunctionCall1Coll(), ereport, errcode(), errhint(), errmsg(), ERROR, GetDatabaseEncoding(), lc_ctype_is_c(), locale, lower(), MB_MatchText(), OidIsValid, pg_database_encoding_max_length(), pg_newlocale_from_collation(), PG_UTF8, PointerGetDatum, SB_IMatchText(), generate_unaccent_rules::str, UTF8_MatchText(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.

Referenced by nameiclike(), nameicnlike(), texticlike(), and texticnlike().

◆ GenericMatchText()

static int GenericMatchText ( const char *  s,
int  slen,
const char *  p,
int  plen,
Oid  collation 
)
inlinestatic

Definition at line 151 of file like.c.

152 {
153  if (collation && !lc_ctype_is_c(collation))
154  {
156 
157  if (locale && !locale->deterministic)
158  ereport(ERROR,
159  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
160  errmsg("nondeterministic collations are not supported for LIKE")));
161  }
162 
164  return SB_MatchText(s, slen, p, plen, 0, true);
165  else if (GetDatabaseEncoding() == PG_UTF8)
166  return UTF8_MatchText(s, slen, p, plen, 0, true);
167  else
168  return MB_MatchText(s, slen, p, plen, 0, true);
169 }

References ereport, errcode(), errmsg(), ERROR, GetDatabaseEncoding(), lc_ctype_is_c(), locale, MB_MatchText(), pg_database_encoding_max_length(), pg_newlocale_from_collation(), PG_UTF8, SB_MatchText(), and UTF8_MatchText().

Referenced by namelike(), namenlike(), textlike(), and textnlike().

◆ like_escape()

Datum like_escape ( PG_FUNCTION_ARGS  )

Definition at line 429 of file like.c.

430 {
431  text *pat = PG_GETARG_TEXT_PP(0);
432  text *esc = PG_GETARG_TEXT_PP(1);
433  text *result;
434 
436  result = SB_do_like_escape(pat, esc);
437  else
438  result = MB_do_like_escape(pat, esc);
439 
440  PG_RETURN_TEXT_P(result);
441 }
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:309
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:372
static text * SB_do_like_escape(text *, text *)
static text * MB_do_like_escape(text *, text *)

References MB_do_like_escape(), pg_database_encoding_max_length(), PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, and SB_do_like_escape().

◆ like_escape_bytea()

Datum like_escape_bytea ( PG_FUNCTION_ARGS  )

Definition at line 448 of file like.c.

449 {
450  bytea *pat = PG_GETARG_BYTEA_PP(0);
451  bytea *esc = PG_GETARG_BYTEA_PP(1);
452  bytea *result = SB_do_like_escape((text *) pat, (text *) esc);
453 
454  PG_RETURN_BYTEA_P((bytea *) result);
455 }
#define PG_RETURN_BYTEA_P(x)
Definition: fmgr.h:371

References PG_GETARG_BYTEA_PP, PG_RETURN_BYTEA_P, and SB_do_like_escape().

◆ MB_do_like_escape()

static text* MB_do_like_escape ( text ,
text  
)
static

Referenced by like_escape().

◆ MB_MatchText()

static int MB_MatchText ( const char *  t,
int  tlen,
const char *  p,
int  plen,
pg_locale_t  locale,
bool  locale_is_c 
)
static

◆ nameiclike()

Datum nameiclike ( PG_FUNCTION_ARGS  )

Definition at line 371 of file like.c.

372 {
373  Name str = PG_GETARG_NAME(0);
374  text *pat = PG_GETARG_TEXT_PP(1);
375  bool result;
376  text *strtext;
377 
379  NameGetDatum(str)));
380  result = (Generic_Text_IC_like(strtext, pat, PG_GET_COLLATION()) == LIKE_TRUE);
381 
382  PG_RETURN_BOOL(result);
383 }
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:631
#define PG_GETARG_NAME(n)
Definition: fmgr.h:278
#define PG_GET_COLLATION()
Definition: fmgr.h:198
static int Generic_Text_IC_like(text *str, text *pat, Oid collation)
Definition: like.c:172
#define NameGetDatum(X)
Definition: postgres.h:639
Definition: c.h:687
Datum name_text(PG_FUNCTION_ARGS)
Definition: varlena.c:3640

References DatumGetTextPP, DirectFunctionCall1, Generic_Text_IC_like(), LIKE_TRUE, name_text(), NameGetDatum, PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and generate_unaccent_rules::str.

◆ nameicnlike()

Datum nameicnlike ( PG_FUNCTION_ARGS  )

Definition at line 386 of file like.c.

387 {
388  Name str = PG_GETARG_NAME(0);
389  text *pat = PG_GETARG_TEXT_PP(1);
390  bool result;
391  text *strtext;
392 
394  NameGetDatum(str)));
395  result = (Generic_Text_IC_like(strtext, pat, PG_GET_COLLATION()) != LIKE_TRUE);
396 
397  PG_RETURN_BOOL(result);
398 }

References DatumGetTextPP, DirectFunctionCall1, Generic_Text_IC_like(), LIKE_TRUE, name_text(), NameGetDatum, PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and generate_unaccent_rules::str.

◆ namelike()

Datum namelike ( PG_FUNCTION_ARGS  )

Definition at line 241 of file like.c.

242 {
243  Name str = PG_GETARG_NAME(0);
244  text *pat = PG_GETARG_TEXT_PP(1);
245  bool result;
246  char *s,
247  *p;
248  int slen,
249  plen;
250 
251  s = NameStr(*str);
252  slen = strlen(s);
253  p = VARDATA_ANY(pat);
254  plen = VARSIZE_ANY_EXHDR(pat);
255 
256  result = (GenericMatchText(s, slen, p, plen, PG_GET_COLLATION()) == LIKE_TRUE);
257 
258  PG_RETURN_BOOL(result);
259 }
#define NameStr(name)
Definition: c.h:692
static int GenericMatchText(const char *s, int slen, const char *p, int plen, Oid collation)
Definition: like.c:151

References GenericMatchText(), LIKE_TRUE, NameStr, PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, generate_unaccent_rules::str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ namenlike()

Datum namenlike ( PG_FUNCTION_ARGS  )

Definition at line 262 of file like.c.

263 {
264  Name str = PG_GETARG_NAME(0);
265  text *pat = PG_GETARG_TEXT_PP(1);
266  bool result;
267  char *s,
268  *p;
269  int slen,
270  plen;
271 
272  s = NameStr(*str);
273  slen = strlen(s);
274  p = VARDATA_ANY(pat);
275  plen = VARSIZE_ANY_EXHDR(pat);
276 
277  result = (GenericMatchText(s, slen, p, plen, PG_GET_COLLATION()) != LIKE_TRUE);
278 
279  PG_RETURN_BOOL(result);
280 }

References GenericMatchText(), LIKE_TRUE, NameStr, PG_GET_COLLATION, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, generate_unaccent_rules::str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ SB_do_like_escape()

static text* SB_do_like_escape ( text ,
text  
)
static

Referenced by like_escape(), and like_escape_bytea().

◆ SB_IMatchText()

static int SB_IMatchText ( const char *  t,
int  tlen,
const char *  p,
int  plen,
pg_locale_t  locale,
bool  locale_is_c 
)
static

Referenced by Generic_Text_IC_like().

◆ SB_lower_char()

static char SB_lower_char ( unsigned char  c,
pg_locale_t  locale,
bool  locale_is_c 
)
static

Definition at line 93 of file like.c.

94 {
95  if (locale_is_c)
96  return pg_ascii_tolower(c);
97 #ifdef HAVE_LOCALE_T
98  else if (locale)
99  return tolower_l(c, locale->info.lt);
100 #endif
101  else
102  return pg_tolower(c);
103 }
unsigned char pg_tolower(unsigned char ch)
Definition: pgstrcasecmp.c:122
unsigned char pg_ascii_tolower(unsigned char ch)
Definition: pgstrcasecmp.c:146
char * c
#define tolower_l
Definition: win32_port.h:402

References locale, pg_ascii_tolower(), pg_tolower(), and tolower_l.

◆ SB_MatchText()

static int SB_MatchText ( const char *  t,
int  tlen,
const char *  p,
int  plen,
pg_locale_t  locale,
bool  locale_is_c 
)
static

◆ texticlike()

Datum texticlike ( PG_FUNCTION_ARGS  )

Definition at line 401 of file like.c.

402 {
403  text *str = PG_GETARG_TEXT_PP(0);
404  text *pat = PG_GETARG_TEXT_PP(1);
405  bool result;
406 
407  result = (Generic_Text_IC_like(str, pat, PG_GET_COLLATION()) == LIKE_TRUE);
408 
409  PG_RETURN_BOOL(result);
410 }

References Generic_Text_IC_like(), LIKE_TRUE, PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and generate_unaccent_rules::str.

◆ texticnlike()

Datum texticnlike ( PG_FUNCTION_ARGS  )

Definition at line 413 of file like.c.

414 {
415  text *str = PG_GETARG_TEXT_PP(0);
416  text *pat = PG_GETARG_TEXT_PP(1);
417  bool result;
418 
419  result = (Generic_Text_IC_like(str, pat, PG_GET_COLLATION()) != LIKE_TRUE);
420 
421  PG_RETURN_BOOL(result);
422 }

References Generic_Text_IC_like(), LIKE_TRUE, PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and generate_unaccent_rules::str.

◆ textlike()

Datum textlike ( PG_FUNCTION_ARGS  )

Definition at line 283 of file like.c.

284 {
285  text *str = PG_GETARG_TEXT_PP(0);
286  text *pat = PG_GETARG_TEXT_PP(1);
287  bool result;
288  char *s,
289  *p;
290  int slen,
291  plen;
292 
293  s = VARDATA_ANY(str);
294  slen = VARSIZE_ANY_EXHDR(str);
295  p = VARDATA_ANY(pat);
296  plen = VARSIZE_ANY_EXHDR(pat);
297 
298  result = (GenericMatchText(s, slen, p, plen, PG_GET_COLLATION()) == LIKE_TRUE);
299 
300  PG_RETURN_BOOL(result);
301 }

References GenericMatchText(), LIKE_TRUE, PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, generate_unaccent_rules::str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ textnlike()

Datum textnlike ( PG_FUNCTION_ARGS  )

Definition at line 304 of file like.c.

305 {
306  text *str = PG_GETARG_TEXT_PP(0);
307  text *pat = PG_GETARG_TEXT_PP(1);
308  bool result;
309  char *s,
310  *p;
311  int slen,
312  plen;
313 
314  s = VARDATA_ANY(str);
315  slen = VARSIZE_ANY_EXHDR(str);
316  p = VARDATA_ANY(pat);
317  plen = VARSIZE_ANY_EXHDR(pat);
318 
319  result = (GenericMatchText(s, slen, p, plen, PG_GET_COLLATION()) != LIKE_TRUE);
320 
321  PG_RETURN_BOOL(result);
322 }

References GenericMatchText(), LIKE_TRUE, PG_GET_COLLATION, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, generate_unaccent_rules::str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.

◆ UTF8_MatchText()

static int UTF8_MatchText ( const char *  t,
int  tlen,
const char *  p,
int  plen,
pg_locale_t  locale,
bool  locale_is_c 
)
static

◆ wchareq()

static int wchareq ( const char *  p1,
const char *  p2 
)
inlinestatic

Definition at line 57 of file like.c.

58 {
59  int p1_len;
60 
61  /* Optimization: quickly compare the first byte. */
62  if (*p1 != *p2)
63  return 0;
64 
65  p1_len = pg_mblen(p1);
66  if (pg_mblen(p2) != p1_len)
67  return 0;
68 
69  /* They are the same length */
70  while (p1_len--)
71  {
72  if (*p1++ != *p2++)
73  return 0;
74  }
75  return 1;
76 }

References p2, and pg_mblen().