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 C_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);
93#define NextByte(p, plen) ((p)++, (plen)--)
96#define CHAREQ(p1, p2) wchareq((p1), (p2))
97#define NextChar(p, plen) \
98 do { int __l = pg_mblen(p); (p) +=__l; (plen) -=__l; } while (0)
99#define CopyAdvChar(dst, src, srclen) \
100 do { int __l = pg_mblen(src); \
103 *(dst)++ = *(src)++; \
106#define MatchText MB_MatchText
107#define do_like_escape MB_do_like_escape
112#define CHAREQ(p1, p2) (*(p1) == *(p2))
113#define NextChar(p, plen) NextByte((p), (plen))
114#define CopyAdvChar(dst, src, srclen) (*(dst)++ = *(src)++, (srclen)--)
116#define MatchText SB_MatchText
117#define do_like_escape SB_do_like_escape
123#define NextChar(p, plen) NextByte((p), (plen))
124#define MatchText C_IMatchText
130#define NextChar(p, plen) \
131 do { (p)++; (plen)--; } while ((plen) > 0 && (*(p) & 0xC0) == 0x80 )
132#define MatchText UTF8_MatchText
149 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
150 errmsg(
"could not determine which collation to use for LIKE"),
151 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
180 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
181 errmsg(
"could not determine which collation to use for ILIKE"),
182 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
187 if (!
locale->deterministic)
189 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
190 errmsg(
"nondeterministic collations are not supported for ILIKE")));
#define OidIsValid(objectId)
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)
static int C_IMatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale)
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)
Datum nameicnlike(PG_FUNCTION_ARGS)
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)
static Datum PointerGetDatum(const void *X)
static Datum NameGetDatum(const NameData *X)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
Datum name_text(PG_FUNCTION_ARGS)