32 #define LIKE_ABORT (-1)
35 static int SB_MatchText(
const char *t,
int tlen,
const char *p,
int plen,
39 static int MB_MatchText(
const char *t,
int tlen,
const char *p,
int plen,
46 static int SB_IMatchText(
const char *t,
int tlen,
const char *p,
int plen,
49 static int GenericMatchText(
const char *s,
int slen,
const char *p,
int plen,
Oid collation);
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) SB_lower_char((unsigned char) (t), locale, locale_is_c)
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
158 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
159 errmsg(
"nondeterministic collations are not supported for LIKE")));
178 bool locale_is_c =
false;
187 (
errcode(ERRCODE_INDETERMINATE_COLLATION),
188 errmsg(
"could not determine which collation to use for ILIKE"),
189 errhint(
"Use the COLLATE clause to set the collation explicitly.")));
199 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
200 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 text * SB_do_like_escape(text *pat, text *esc)
static int SB_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
static char SB_lower_char(unsigned char c, pg_locale_t locale, bool locale_is_c)
Datum texticnlike(PG_FUNCTION_ARGS)
Datum textlike(PG_FUNCTION_ARGS)
Datum namelike(PG_FUNCTION_ARGS)
Datum nameiclike(PG_FUNCTION_ARGS)
static int UTF8_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
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, bool locale_is_c)
Datum nameicnlike(PG_FUNCTION_ARGS)
Datum like_escape_bytea(PG_FUNCTION_ARGS)
static int MB_MatchText(const char *t, int tlen, const char *p, int plen, pg_locale_t locale, bool locale_is_c)
static text * MB_do_like_escape(text *pat, text *esc)
Datum texticlike(PG_FUNCTION_ARGS)
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)
bool lc_ctype_is_c(Oid collation)
bool pg_locale_deterministic(pg_locale_t locale)
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)