18#define LTREE_LABEL_MAX_CHARS 1000
39#define LEVEL_HDRSIZE (offsetof(ltree_level,name))
40#define LEVEL_NEXT(x) ( (ltree_level*)( ((char*)(x)) + MAXALIGN(((ltree_level*)(x))->len + LEVEL_HDRSIZE) ) )
50#define LTREE_HDRSIZE MAXALIGN( offsetof(ltree, data) )
51#define LTREE_FIRST(x) ( (ltree_level*)( ((char*)(x))+LTREE_HDRSIZE ) )
52#define LTREE_MAX_LEVELS PG_UINT16_MAX
71#define LVAR_HDRSIZE MAXALIGN(offsetof(lquery_variant, name))
72#define LVAR_NEXT(x) ( (lquery_variant*)( ((char*)(x)) + MAXALIGN(((lquery_variant*)(x))->len) + LVAR_HDRSIZE ) )
74#define LVAR_ANYEND 0x01
75#define LVAR_INCASE 0x02
76#define LVAR_SUBLEXEME 0x04
99#define LQL_HDRSIZE MAXALIGN( offsetof(lquery_level,variants) )
100#define LQL_NEXT(x) ( (lquery_level*)( ((char*)(x)) + MAXALIGN(((lquery_level*)(x))->totallen) ) )
101#define LQL_FIRST(x) ( (lquery_variant*)( ((char*)(x))+LQL_HDRSIZE ) )
104#define LQL_COUNT 0x20
107#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME ) ) == 0 )
109#define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 )
111#define LQL_CANLOOKSIGN(x) FLG_CANLOOKSIGN( ((lquery_level*)(x))->flag )
123#define LQUERY_HDRSIZE MAXALIGN( offsetof(lquery, data) )
124#define LQUERY_FIRST(x) ( (lquery_level*)( ((char*)(x))+LQUERY_HDRSIZE ) )
125#define LQUERY_MAX_LEVELS PG_UINT16_MAX
127#define LQUERY_HASNOT 0x01
130#define ISLABEL(x) ( t_isalnum(x) || t_iseq(x, '_') || t_iseq(x, '-') )
160#define HDRSIZEQT MAXALIGN(VARHDRSZ + sizeof(int32))
161#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) )
162#define LTXTQUERY_TOO_BIG(size,lenofoperand) \
163 ((size) > (MaxAllocSize - HDRSIZEQT - (lenofoperand)) / sizeof(ITEM))
164#define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT )
165#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((ltxtquery*)x)->size * sizeof(ITEM) )
167#define ISOPERATOR(x) ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' )
206 bool calcnot,
bool (*chkcond) (
void *checkval,
ITEM *
val));
211 int (*cmpptr) (
const char *,
const char *,
size_t),
bool anyend);
216#define DatumGetLtreeP(X) ((ltree *) PG_DETOAST_DATUM(X))
217#define DatumGetLtreePCopy(X) ((ltree *) PG_DETOAST_DATUM_COPY(X))
218#define PG_GETARG_LTREE_P(n) DatumGetLtreeP(PG_GETARG_DATUM(n))
219#define PG_GETARG_LTREE_P_COPY(n) DatumGetLtreePCopy(PG_GETARG_DATUM(n))
221#define DatumGetLqueryP(X) ((lquery *) PG_DETOAST_DATUM(X))
222#define DatumGetLqueryPCopy(X) ((lquery *) PG_DETOAST_DATUM_COPY(X))
223#define PG_GETARG_LQUERY_P(n) DatumGetLqueryP(PG_GETARG_DATUM(n))
224#define PG_GETARG_LQUERY_P_COPY(n) DatumGetLqueryPCopy(PG_GETARG_DATUM(n))
226#define DatumGetLtxtqueryP(X) ((ltxtquery *) PG_DETOAST_DATUM(X))
227#define DatumGetLtxtqueryPCopy(X) ((ltxtquery *) PG_DETOAST_DATUM_COPY(X))
228#define PG_GETARG_LTXTQUERY_P(n) DatumGetLtxtqueryP(PG_GETARG_DATUM(n))
229#define PG_GETARG_LTXTQUERY_P_COPY(n) DatumGetLtxtqueryPCopy(PG_GETARG_DATUM(n))
234#define SIGLENBIT(siglen) ((siglen) * BITBYTE)
235#define LTREE_SIGLEN_DEFAULT (2 * sizeof(int32))
236#define LTREE_SIGLEN_MAX GISTMaxIndexKeySize
237#define LTREE_GET_SIGLEN() (PG_HAS_OPCLASS_OPTIONS() ? \
238 ((LtreeGistOptions *) PG_GET_OPCLASS_OPTIONS())->siglen : \
239 LTREE_SIGLEN_DEFAULT)
243#define LOOPBYTE(siglen) \
244 for(i = 0; i < (siglen); i++)
246#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) )
247#define GETBITBYTE(x,i) ( ((unsigned char)(x)) >> i & 0x01 )
248#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) )
249#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) )
250#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 )
252#define HASHVAL(val, siglen) (((unsigned int)(val)) % SIGLENBIT(siglen))
253#define HASH(sign, val, siglen) SETBIT((sign), HASHVAL(val, siglen))
273#define LTG_ONENODE 0x01
274#define LTG_ALLTRUE 0x02
275#define LTG_NORIGHT 0x04
277#define LTG_HDRSIZE MAXALIGN(VARHDRSZ + sizeof(uint32))
278#define LTG_SIGN(x) ( (BITVECP)( ((char*)(x))+LTG_HDRSIZE ) )
279#define LTG_NODE(x) ( (ltree*)( ((char*)(x))+LTG_HDRSIZE ) )
280#define LTG_ISONENODE(x) ( ((ltree_gist*)(x))->flag & LTG_ONENODE )
281#define LTG_ISALLTRUE(x) ( ((ltree_gist*)(x))->flag & LTG_ALLTRUE )
282#define LTG_ISNORIGHT(x) ( ((ltree_gist*)(x))->flag & LTG_NORIGHT )
283#define LTG_LNODE(x, siglen) ( (ltree*)( ( ((char*)(x))+LTG_HDRSIZE ) + ( LTG_ISALLTRUE(x) ? 0 : (siglen) ) ) )
284#define LTG_RENODE(x, siglen) ( (ltree*)( ((char*)LTG_LNODE(x, siglen)) + VARSIZE(LTG_LNODE(x, siglen))) )
285#define LTG_RNODE(x, siglen) ( LTG_ISNORIGHT(x) ? LTG_LNODE(x, siglen) : LTG_RENODE(x, siglen) )
287#define LTG_GETLNODE(x, siglen) ( LTG_ISONENODE(x) ? LTG_NODE(x) : LTG_LNODE(x, siglen) )
288#define LTG_GETRNODE(x, siglen) ( LTG_ISONENODE(x) ? LTG_NODE(x) : LTG_RNODE(x, siglen) )
295#define LTREE_ASIGLEN_DEFAULT (7 * sizeof(int32))
296#define LTREE_ASIGLEN_MAX GISTMaxIndexKeySize
297#define LTREE_GET_ASIGLEN() (PG_HAS_OPCLASS_OPTIONS() ? \
298 ((LtreeGistOptions *) PG_GET_OPCLASS_OPTIONS())->siglen : \
299 LTREE_ASIGLEN_DEFAULT)
300#define ASIGLENBIT(siglen) ((siglen) * BITBYTE)
302#define ALOOPBYTE(siglen) \
303 for (i = 0; i < (siglen); i++)
305#define AHASHVAL(val, siglen) (((unsigned int)(val)) % ASIGLENBIT(siglen))
306#define AHASH(sign, val, siglen) SETBIT((sign), AHASHVAL(val, siglen))
#define FLEXIBLE_ARRAY_MEMBER
bool inner_isparent(const ltree *c, const ltree *p)
PGDLLEXPORT Datum ltree_addtext(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum ltree_addltree(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum ltxtq_exec(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum ltxtq_rexec(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum ltq_rregex(PG_FUNCTION_ARGS)
ltree * lca_inner(ltree **a, int len)
int ltree_compare(const ltree *a, const ltree *b)
PGDLLEXPORT Datum _ltq_rregex(PG_FUNCTION_ARGS)
bool compare_subnode(ltree_level *t, char *qn, int len, int(*cmpptr)(const char *, const char *, size_t), bool anyend)
PGDLLEXPORT Datum _ltree_isparent(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum lt_q_rregex(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum ltree_risparent(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum ltree_isparent(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum ltq_regex(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum ltree_textadd(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum _ltree_risparent(PG_FUNCTION_ARGS)
int ltree_strncasecmp(const char *a, const char *b, size_t s)
PGDLLEXPORT Datum lt_q_regex(PG_FUNCTION_ARGS)
bool ltree_execute(ITEM *curitem, void *checkval, bool calcnot, bool(*chkcond)(void *checkval, ITEM *val))
PGDLLEXPORT Datum _lt_q_regex(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum _ltq_regex(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum _ltxtq_exec(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum _ltxtq_rexec(PG_FUNCTION_ARGS)
PGDLLEXPORT Datum _lt_q_rregex(PG_FUNCTION_ARGS)
ltree_gist * ltree_gist_alloc(bool isalltrue, BITVECP sign, int siglen, ltree *left, ltree *right)
PGDLLEXPORT Datum ltree_in(PG_FUNCTION_ARGS)