25#include "utils/fmgrprotos.h"
32#define LIKE_ABORT (-1)
35static int SB_MatchText(
const char *t,
int tlen,
const char *p,
int plen,
39static int MB_MatchText(
const char *t,
int tlen,
const char *p,
int plen,
46static int SB_IMatchText(
const char *t,
int tlen,
const char *p,
int plen,
49static int GenericMatchText(
const char *s,
int slen,
const char *p,
int plen,
Oid collation);
98 else if (
locale->is_default)
105#define NextByte(p, plen) ((p)++, (plen)--)
108#define CHAREQ(p1, p2) wchareq((p1), (p2))
109#define NextChar(p, plen) \
110 do { int __l = pg_mblen(p); (p) +=__l; (plen) -=__l; } while (0)
111#define CopyAdvChar(dst, src, srclen) \
112 do { int __l = pg_mblen(src); \
115 *(dst)++ = *(src)++; \
118#define MatchText MB_MatchText
119#define do_like_escape MB_do_like_escape
124#define CHAREQ(p1, p2) (*(p1) == *(p2))
125#define NextChar(p, plen) NextByte((p), (plen))
126#define CopyAdvChar(dst, src, srclen) (*(dst)++ = *(src)++, (srclen)--)
128#define MatchText SB_MatchText
129#define do_like_escape SB_do_like_escape
134#define MATCH_LOWER(t, locale) SB_lower_char((unsigned char) (t), locale)
135#define NextChar(p, plen) NextByte((p), (plen))
136#define MatchText SB_IMatchText
142#define NextChar(p, plen) \
143 do { (p)++; (plen)--; } while ((plen) > 0 && (*(p) & 0xC0) == 0x80 )
144#define MatchText UTF8_MatchText
161 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
162 errmsg(
"could not determine which collation to use for LIKE"),
163 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
192 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
193 errmsg(
"could not determine which collation to use for ILIKE"),
194 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
199 if (!
locale->deterministic)
201 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
202 errmsg(
"nondeterministic collations are not supported for ILIKE")));
#define OidIsValid(objectId)
static void PGresult const char * p2
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Datum DirectFunctionCall1Coll(PGFunction func, Oid collation, Datum arg1)
#define PG_GETARG_BYTEA_PP(n)
#define PG_GETARG_TEXT_PP(n)
#define PG_RETURN_BYTEA_P(x)
#define DatumGetTextPP(X)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_NAME(n)
#define PG_RETURN_TEXT_P(x)
#define PG_GET_COLLATION()
#define PG_RETURN_BOOL(x)
static int UTF8_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale)
static int MB_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale)
static text * MB_do_like_escape(text *pat, text *esc)
Datum texticnlike(PG_FUNCTION_ARGS)
Datum textlike(PG_FUNCTION_ARGS)
Datum namelike(PG_FUNCTION_ARGS)
Datum nameiclike(PG_FUNCTION_ARGS)
Datum byteanlike(PG_FUNCTION_ARGS)
Datum like_escape(PG_FUNCTION_ARGS)
static int wchareq(const char *p1, const char *p2)
Datum namenlike(PG_FUNCTION_ARGS)
Datum textnlike(PG_FUNCTION_ARGS)
static int SB_IMatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale)
Datum nameicnlike(PG_FUNCTION_ARGS)
static char SB_lower_char(unsigned char c, pg_locale_t locale)
Datum like_escape_bytea(PG_FUNCTION_ARGS)
static text * SB_do_like_escape(text *pat, text *esc)
Datum texticlike(PG_FUNCTION_ARGS)
static int SB_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale)
static int Generic_Text_IC_like(text *str, text *pat, Oid collation)
Datum bytealike(PG_FUNCTION_ARGS)
static int GenericMatchText(const char *s, int slen, const char *p, int plen, Oid collation)
int GetDatabaseEncoding(void)
int pg_database_encoding_max_length(void)
int pg_mblen(const char *mbstr)
Datum lower(PG_FUNCTION_ARGS)
pg_locale_t pg_newlocale_from_collation(Oid collid)
unsigned char pg_tolower(unsigned char ch)
unsigned char pg_ascii_tolower(unsigned char ch)
static Datum PointerGetDatum(const void *X)
static Datum NameGetDatum(const NameData *X)
#define VARSIZE_ANY_EXHDR(PTR)
Datum name_text(PG_FUNCTION_ARGS)