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 "varatt.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 *pat, text *esc)
 
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 *pat, text *esc)
 
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 126 of file like.c.

◆ CHAREQ [2/2]

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

Definition at line 126 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:1024

Definition at line 128 of file like.c.

◆ CopyAdvChar [2/2]

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

Definition at line 128 of file like.c.

◆ do_like_escape [1/2]

#define do_like_escape   MB_do_like_escape

Definition at line 131 of file like.c.

◆ do_like_escape [2/2]

#define do_like_escape   SB_do_like_escape

Definition at line 131 of file like.c.

◆ LIKE_ABORT

#define LIKE_ABORT   (-1)

Definition at line 32 of file like.c.

◆ LIKE_FALSE

#define LIKE_FALSE   0

Definition at line 31 of file like.c.

◆ LIKE_TRUE

#define LIKE_TRUE   1

Definition at line 30 of file like.c.

◆ MATCH_LOWER

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

Definition at line 136 of file like.c.

◆ MatchText [1/4]

#define MatchText   MB_MatchText

Definition at line 146 of file like.c.

◆ MatchText [2/4]

#define MatchText   SB_MatchText

Definition at line 146 of file like.c.

◆ MatchText [3/4]

#define MatchText   SB_IMatchText

Definition at line 146 of file like.c.

◆ MatchText [4/4]

#define MatchText   UTF8_MatchText

Definition at line 146 of file like.c.

◆ NextByte

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

Definition at line 107 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 144 of file like.c.

◆ NextChar [2/4]

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

Definition at line 144 of file like.c.

◆ NextChar [3/4]

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

Definition at line 144 of file like.c.

◆ NextChar [4/4]

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

Definition at line 144 of file like.c.

Function Documentation

◆ bytealike()

Datum bytealike ( PG_FUNCTION_ARGS  )

Definition at line 326 of file like.c.

327 {
329  bytea *pat = PG_GETARG_BYTEA_PP(1);
330  bool result;
331  char *s,
332  *p;
333  int slen,
334  plen;
335 
336  s = VARDATA_ANY(str);
337  slen = VARSIZE_ANY_EXHDR(str);
338  p = VARDATA_ANY(pat);
339  plen = VARSIZE_ANY_EXHDR(pat);
340 
341  result = (SB_MatchText(s, slen, p, plen, 0, true) == LIKE_TRUE);
342 
343  PG_RETURN_BOOL(result);
344 }
#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:30
Definition: c.h:671
#define VARDATA_ANY(PTR)
Definition: varatt.h:324
#define VARSIZE_ANY_EXHDR(PTR)
Definition: varatt.h:317

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 347 of file like.c.

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

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 173 of file like.c.

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

References DatumGetTextPP, DirectFunctionCall1Coll(), ereport, errcode(), errhint(), errmsg(), ERROR, GetDatabaseEncoding(), lc_ctype_is_c(), locale, lower(), MB_MatchText(), OidIsValid, pg_database_encoding_max_length(), pg_locale_deterministic(), 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 152 of file like.c.

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

References ereport, errcode(), errmsg(), ERROR, GetDatabaseEncoding(), lc_ctype_is_c(), locale, MB_MatchText(), pg_database_encoding_max_length(), pg_locale_deterministic(), 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 430 of file like.c.

431 {
432  text *pat = PG_GETARG_TEXT_PP(0);
433  text *esc = PG_GETARG_TEXT_PP(1);
434  text *result;
435 
437  result = SB_do_like_escape(pat, esc);
438  else
439  result = MB_do_like_escape(pat, esc);
440 
441  PG_RETURN_TEXT_P(result);
442 }
#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 *pat, text *esc)
static text * MB_do_like_escape(text *pat, text *esc)

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 449 of file like.c.

450 {
451  bytea *pat = PG_GETARG_BYTEA_PP(0);
452  bytea *esc = PG_GETARG_BYTEA_PP(1);
453  bytea *result = SB_do_like_escape((text *) pat, (text *) esc);
454 
455  PG_RETURN_BYTEA_P((bytea *) result);
456 }
#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 pat,
text esc 
)
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 372 of file like.c.

373 {
374  Name str = PG_GETARG_NAME(0);
375  text *pat = PG_GETARG_TEXT_PP(1);
376  bool result;
377  text *strtext;
378 
380  NameGetDatum(str)));
381  result = (Generic_Text_IC_like(strtext, pat, PG_GET_COLLATION()) == LIKE_TRUE);
382 
383  PG_RETURN_BOOL(result);
384 }
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:642
#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:173
static Datum NameGetDatum(const NameData *X)
Definition: postgres.h:373
Definition: c.h:725
Datum name_text(PG_FUNCTION_ARGS)
Definition: varlena.c:3379

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 387 of file like.c.

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

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 242 of file like.c.

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

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 263 of file like.c.

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

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 pat,
text esc 
)
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 94 of file like.c.

95 {
96  if (locale_is_c)
97  return pg_ascii_tolower(c);
98 #ifdef HAVE_LOCALE_T
99  else if (locale)
100  return tolower_l(c, locale->info.lt);
101 #endif
102  else
103  return pg_tolower(c);
104 }
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:433

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 402 of file like.c.

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

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 414 of file like.c.

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

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 284 of file like.c.

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

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 305 of file like.c.

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

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 58 of file like.c.

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

References p2, and pg_mblen().