#include "fmgr.h"#include "tsearch/ts_locale.h"

Go to the source code of this file.
Data Structures | |
| struct | ltree_level |
| struct | ltree |
| struct | lquery_variant |
| struct | lquery_level |
| struct | lquery |
| struct | ITEM |
| struct | ltxtquery |
| struct | ltree_gist |
Defines | |
| #define | LEVEL_HDRSIZE (offsetof(ltree_level,name)) |
| #define | LEVEL_NEXT(x) ( (ltree_level*)( ((char*)(x)) + MAXALIGN(((ltree_level*)(x))->len + LEVEL_HDRSIZE) ) ) |
| #define | LTREE_HDRSIZE MAXALIGN( offsetof(ltree, data) ) |
| #define | LTREE_FIRST(x) ( (ltree_level*)( ((char*)(x))+LTREE_HDRSIZE ) ) |
| #define | LVAR_HDRSIZE MAXALIGN(offsetof(lquery_variant, name)) |
| #define | LVAR_NEXT(x) ( (lquery_variant*)( ((char*)(x)) + MAXALIGN(((lquery_variant*)(x))->len) + LVAR_HDRSIZE ) ) |
| #define | LVAR_ANYEND 0x01 |
| #define | LVAR_INCASE 0x02 |
| #define | LVAR_SUBLEXEME 0x04 |
| #define | LQL_HDRSIZE MAXALIGN( offsetof(lquery_level,variants) ) |
| #define | LQL_NEXT(x) ( (lquery_level*)( ((char*)(x)) + MAXALIGN(((lquery_level*)(x))->totallen) ) ) |
| #define | LQL_FIRST(x) ( (lquery_variant*)( ((char*)(x))+LQL_HDRSIZE ) ) |
| #define | LQL_NOT 0x10 |
| #define | FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 ) |
| #define | LQL_CANLOOKSIGN(x) FLG_CANLOOKSIGN( ((lquery_level*)(x))->flag ) |
| #define | LQUERY_HDRSIZE MAXALIGN( offsetof(lquery, data) ) |
| #define | LQUERY_FIRST(x) ( (lquery_level*)( ((char*)(x))+LQUERY_HDRSIZE ) ) |
| #define | LQUERY_HASNOT 0x01 |
| #define | ISALNUM(x) ( t_isalpha(x) || t_isdigit(x) || ( pg_mblen(x) == 1 && t_iseq((x), '_') ) ) |
| #define | HDRSIZEQT MAXALIGN(VARHDRSZ + sizeof(int32)) |
| #define | COMPUTESIZE(size, lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) ) |
| #define | GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT ) |
| #define | GETOPERAND(x) ( (char*)GETQUERY(x) + ((ltxtquery*)x)->size * sizeof(ITEM) ) |
| #define | ISOPERATOR(x) ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' ) |
| #define | END 0 |
| #define | ERR 1 |
| #define | VAL 2 |
| #define | OPR 3 |
| #define | OPEN 4 |
| #define | CLOSE 5 |
| #define | VALTRUE 6 |
| #define | VALFALSE 7 |
| #define | PG_GETARG_LTREE(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) |
| #define | PG_GETARG_LTREE_COPY(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x)))) |
| #define | PG_GETARG_LQUERY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) |
| #define | PG_GETARG_LQUERY_COPY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x)))) |
| #define | PG_GETARG_LTXTQUERY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) |
| #define | PG_GETARG_LTXTQUERY_COPY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x)))) |
| #define | BITBYTE 8 |
| #define | SIGLENINT 2 |
| #define | SIGLEN ( sizeof(int32)*SIGLENINT ) |
| #define | SIGLENBIT (SIGLEN*BITBYTE) |
| #define | LOOPBYTE for(i=0;i<SIGLEN;i++) |
| #define | GETBYTE(x, i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) ) |
| #define | GETBITBYTE(x, i) ( ((unsigned char)(x)) >> i & 0x01 ) |
| #define | CLRBIT(x, i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) ) |
| #define | SETBIT(x, i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) ) |
| #define | GETBIT(x, i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 ) |
| #define | HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT) |
| #define | HASH(sign, val) SETBIT((sign), HASHVAL(val)) |
| #define | LTG_ONENODE 0x01 |
| #define | LTG_ALLTRUE 0x02 |
| #define | LTG_NORIGHT 0x04 |
| #define | LTG_HDRSIZE MAXALIGN(VARHDRSZ + sizeof(uint32)) |
| #define | LTG_SIGN(x) ( (BITVECP)( ((char*)(x))+LTG_HDRSIZE ) ) |
| #define | LTG_NODE(x) ( (ltree*)( ((char*)(x))+LTG_HDRSIZE ) ) |
| #define | LTG_ISONENODE(x) ( ((ltree_gist*)(x))->flag & LTG_ONENODE ) |
| #define | LTG_ISALLTRUE(x) ( ((ltree_gist*)(x))->flag & LTG_ALLTRUE ) |
| #define | LTG_ISNORIGHT(x) ( ((ltree_gist*)(x))->flag & LTG_NORIGHT ) |
| #define | LTG_LNODE(x) ( (ltree*)( ( ((char*)(x))+LTG_HDRSIZE ) + ( LTG_ISALLTRUE(x) ? 0 : SIGLEN ) ) ) |
| #define | LTG_RENODE(x) ( (ltree*)( ((char*)LTG_LNODE(x)) + VARSIZE(LTG_LNODE(x))) ) |
| #define | LTG_RNODE(x) ( LTG_ISNORIGHT(x) ? LTG_LNODE(x) : LTG_RENODE(x) ) |
| #define | LTG_GETLNODE(x) ( LTG_ISONENODE(x) ? LTG_NODE(x) : LTG_LNODE(x) ) |
| #define | LTG_GETRNODE(x) ( LTG_ISONENODE(x) ? LTG_NODE(x) : LTG_RNODE(x) ) |
| #define | ASIGLENINT (7) |
| #define | ASIGLEN (sizeof(int32)*ASIGLENINT) |
| #define | ASIGLENBIT (ASIGLEN*BITBYTE) |
| #define | ALOOPBYTE for(i=0;i<ASIGLEN;i++) |
| #define | AHASHVAL(val) (((unsigned int)(val)) % ASIGLENBIT) |
| #define | AHASH(sign, val) SETBIT((sign), AHASHVAL(val)) |
Typedefs | |
| typedef struct ITEM | ITEM |
| typedef unsigned char | BITVEC [SIGLEN] |
| typedef unsigned char * | BITVECP |
| typedef unsigned char | ABITVEC [ASIGLEN] |
Functions | |
| Datum | ltree_isparent (PG_FUNCTION_ARGS) |
| Datum | ltree_risparent (PG_FUNCTION_ARGS) |
| Datum | ltq_regex (PG_FUNCTION_ARGS) |
| Datum | ltq_rregex (PG_FUNCTION_ARGS) |
| Datum | lt_q_regex (PG_FUNCTION_ARGS) |
| Datum | lt_q_rregex (PG_FUNCTION_ARGS) |
| Datum | ltxtq_exec (PG_FUNCTION_ARGS) |
| Datum | ltxtq_rexec (PG_FUNCTION_ARGS) |
| Datum | _ltq_regex (PG_FUNCTION_ARGS) |
| Datum | _ltq_rregex (PG_FUNCTION_ARGS) |
| Datum | _lt_q_regex (PG_FUNCTION_ARGS) |
| Datum | _lt_q_rregex (PG_FUNCTION_ARGS) |
| Datum | _ltxtq_exec (PG_FUNCTION_ARGS) |
| Datum | _ltxtq_rexec (PG_FUNCTION_ARGS) |
| Datum | _ltree_isparent (PG_FUNCTION_ARGS) |
| Datum | _ltree_risparent (PG_FUNCTION_ARGS) |
| Datum | ltree_addltree (PG_FUNCTION_ARGS) |
| Datum | ltree_addtext (PG_FUNCTION_ARGS) |
| Datum | ltree_textadd (PG_FUNCTION_ARGS) |
| Datum | ltree_in (PG_FUNCTION_ARGS) |
| bool | ltree_execute (ITEM *curitem, void *checkval, bool calcnot, bool(*chkcond)(void *checkval, ITEM *val)) |
| int | ltree_compare (const ltree *a, const ltree *b) |
| bool | inner_isparent (const ltree *c, const ltree *p) |
| bool | compare_subnode (ltree_level *t, char *q, int len, int(*cmpptr)(const char *, const char *, size_t), bool anyend) |
| ltree * | lca_inner (ltree **a, int len) |
| int | ltree_strncasecmp (const char *a, const char *b, size_t s) |
Definition at line 239 of file ltree.h.
Referenced by checkcondition_bit(), gist_qe(), and gist_te().
Definition at line 236 of file ltree.h.
Referenced by _ltree_compress(), _ltree_picksplit(), _ltree_same(), hemdistsign(), sizebitvec(), and unionkey().
| #define ASIGLEN (sizeof(int32)*ASIGLENINT) |
Definition at line 232 of file ltree.h.
Referenced by _ltree_picksplit(), and _ltree_union().
| #define ASIGLENBIT (ASIGLEN*BITBYTE) |
| #define COMPUTESIZE | ( | size, | ||
| lenofoperand | ||||
| ) | ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) ) |
| #define FLG_CANLOOKSIGN | ( | x | ) | ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 ) |
Definition at line 64 of file ltree.h.
Referenced by checkcondition_bit().
Definition at line 115 of file ltree.h.
Referenced by CompareTSQ(), find_wordentry(), get_docrep(), gin_extract_tsquery(), hlfinditem(), join_tsqueries(), ltxtq_exec(), ltxtq_out(), mcelem_tsquery_selec(), parse_tsquery(), plainto_tsquery_byid(), QTN2QT(), queryin(), SortAndUniqItems(), to_tsquery_byid(), ts_match_vq(), tsa_rewrite_accum(), tsquery_not(), tsquery_rewrite(), tsquery_rewrite_query(), tsqueryout(), tsqueryrecv(), tsquerysend(), and tsquerytree().
| #define ISALNUM | ( | x | ) | ( t_isalpha(x) || t_isdigit(x) || ( pg_mblen(x) == 1 && t_iseq((x), '_') ) ) |
Definition at line 82 of file ltree.h.
Referenced by gettoken_query(), lquery_in(), and ltree_in().
| #define ISOPERATOR | ( | x | ) | ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' ) |
| #define LEVEL_HDRSIZE (offsetof(ltree_level,name)) |
Definition at line 15 of file ltree.h.
Referenced by lca_inner(), and ltree_in().
| #define LEVEL_NEXT | ( | x | ) | ( (ltree_level*)( ((char*)(x)) + MAXALIGN(((ltree_level*)(x))->len + LEVEL_HDRSIZE) ) ) |
Definition at line 16 of file ltree.h.
Referenced by checkCond(), checkcondition_str(), gist_te(), gist_tqcmp(), hashing(), inner_isparent(), inner_subltree(), lca_inner(), ltree2text(), ltree_compare(), ltree_in(), ltree_index(), and ltree_out().
| #define LQL_CANLOOKSIGN | ( | x | ) | FLG_CANLOOKSIGN( ((lquery_level*)(x))->flag ) |
| #define LQL_FIRST | ( | x | ) | ( (lquery_variant*)( ((char*)(x))+LQL_HDRSIZE ) ) |
Definition at line 58 of file ltree.h.
Referenced by checkLevel(), gist_qe(), gist_tqcmp(), lquery_in(), and lquery_out().
| #define LQL_HDRSIZE MAXALIGN( offsetof(lquery_level,variants) ) |
Definition at line 56 of file ltree.h.
Referenced by lquery_in().
| #define LQL_NEXT | ( | x | ) | ( (lquery_level*)( ((char*)(x)) + MAXALIGN(((lquery_level*)(x))->totallen) ) ) |
Definition at line 57 of file ltree.h.
Referenced by checkCond(), gist_qe(), gist_tqcmp(), lquery_in(), and lquery_out().
| #define LQL_NOT 0x10 |
Definition at line 60 of file ltree.h.
Referenced by checkCond(), and lquery_out().
| #define LQUERY_FIRST | ( | x | ) | ( (lquery_level*)( ((char*)(x))+LQUERY_HDRSIZE ) ) |
Definition at line 78 of file ltree.h.
Referenced by gist_qe(), gist_tqcmp(), lquery_in(), lquery_out(), and ltq_regex().
| #define LQUERY_HASNOT 0x01 |
Definition at line 80 of file ltree.h.
Referenced by ltq_regex().
| #define LTG_GETLNODE | ( | x | ) | ( LTG_ISONENODE(x) ? LTG_NODE(x) : LTG_LNODE(x) ) |
Definition at line 225 of file ltree.h.
Referenced by gist_between(), gist_ischild(), gist_isparent(), ltree_consistent(), ltree_penalty(), and ltree_picksplit().
| #define LTG_GETRNODE | ( | x | ) | ( LTG_ISONENODE(x) ? LTG_NODE(x) : LTG_RNODE(x) ) |
Definition at line 226 of file ltree.h.
Referenced by gist_between(), gist_ischild(), gist_isparent(), ltree_consistent(), ltree_penalty(), and ltree_picksplit().
| #define LTG_HDRSIZE MAXALIGN(VARHDRSZ + sizeof(uint32)) |
Definition at line 215 of file ltree.h.
Referenced by _ltree_compress(), _ltree_picksplit(), _ltree_union(), ltree_compress(), ltree_picksplit(), and ltree_union().
| #define LTG_ISALLTRUE | ( | x | ) | ( ((ltree_gist*)(x))->flag & LTG_ALLTRUE ) |
Definition at line 219 of file ltree.h.
Referenced by _ltree_compress(), _ltree_picksplit(), _ltree_same(), _ltree_union(), gist_qe(), gist_qtxt(), gist_te(), hemdist(), ltree_picksplit(), ltree_same(), ltree_union(), and unionkey().
| #define LTG_ISNORIGHT | ( | x | ) | ( ((ltree_gist*)(x))->flag & LTG_NORIGHT ) |
| #define LTG_ISONENODE | ( | x | ) | ( ((ltree_gist*)(x))->flag & LTG_ONENODE ) |
Definition at line 218 of file ltree.h.
Referenced by ltree_picksplit(), ltree_same(), and ltree_union().
| #define LTG_LNODE | ( | x | ) | ( (ltree*)( ( ((char*)(x))+LTG_HDRSIZE ) + ( LTG_ISALLTRUE(x) ? 0 : SIGLEN ) ) ) |
Definition at line 221 of file ltree.h.
Referenced by ltree_picksplit(), ltree_same(), and ltree_union().
| #define LTG_NODE | ( | x | ) | ( (ltree*)( ((char*)(x))+LTG_HDRSIZE ) ) |
Definition at line 217 of file ltree.h.
Referenced by ltree_compress(), ltree_consistent(), ltree_picksplit(), ltree_same(), and ltree_union().
| #define LTG_RENODE | ( | x | ) | ( (ltree*)( ((char*)LTG_LNODE(x)) + VARSIZE(LTG_LNODE(x))) ) |
| #define LTG_RNODE | ( | x | ) | ( LTG_ISNORIGHT(x) ? LTG_LNODE(x) : LTG_RENODE(x) ) |
Definition at line 223 of file ltree.h.
Referenced by ltree_picksplit(), ltree_same(), and ltree_union().
| #define LTG_SIGN | ( | x | ) | ( (BITVECP)( ((char*)(x))+LTG_HDRSIZE ) ) |
Definition at line 216 of file ltree.h.
Referenced by _ltree_compress(), _ltree_picksplit(), _ltree_same(), _ltree_union(), gist_qe(), gist_qtxt(), gist_te(), hemdist(), ltree_picksplit(), ltree_same(), ltree_union(), and unionkey().
| #define LTREE_FIRST | ( | x | ) | ( (ltree_level*)( ((char*)(x))+LTREE_HDRSIZE ) ) |
Definition at line 26 of file ltree.h.
Referenced by checkcondition_str(), gist_te(), gist_tqcmp(), hashing(), inner_isparent(), inner_subltree(), lca_inner(), ltq_regex(), ltree2text(), ltree_compare(), ltree_concat(), ltree_in(), ltree_index(), and ltree_out().
| #define LTREE_HDRSIZE MAXALIGN( offsetof(ltree, data) ) |
Definition at line 25 of file ltree.h.
Referenced by inner_subltree(), lca_inner(), ltree_concat(), and ltree_in().
| #define LVAR_ANYEND 0x01 |
Definition at line 42 of file ltree.h.
Referenced by checkcondition_str(), checkLevel(), infix(), and lquery_out().
| #define LVAR_HDRSIZE MAXALIGN(offsetof(lquery_variant, name)) |
Definition at line 39 of file ltree.h.
Referenced by lquery_in().
| #define LVAR_INCASE 0x02 |
Definition at line 43 of file ltree.h.
Referenced by infix(), and lquery_out().
| #define LVAR_NEXT | ( | x | ) | ( (lquery_variant*)( ((char*)(x)) + MAXALIGN(((lquery_variant*)(x))->len) + LVAR_HDRSIZE ) ) |
Definition at line 40 of file ltree.h.
Referenced by checkLevel(), gist_qe(), lquery_in(), and lquery_out().
| #define LVAR_SUBLEXEME 0x04 |
Definition at line 44 of file ltree.h.
Referenced by checkcondition_str(), checkLevel(), infix(), and lquery_out().
| #define PG_GETARG_LQUERY | ( | x | ) | ((lquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) |
Definition at line 167 of file ltree.h.
Referenced by _ltq_extract_regex(), _ltq_regex(), lquery_out(), ltq_regex(), and ltree_consistent().
| #define PG_GETARG_LQUERY_COPY | ( | x | ) | ((lquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x)))) |
| #define PG_GETARG_LTREE | ( | x | ) | ((ltree*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) |
Definition at line 165 of file ltree.h.
Referenced by _ltree_extract_isparent(), _ltree_extract_risparent(), _ltree_isparent(), _ltree_risparent(), lca(), lt_q_regex(), ltq_regex(), ltree2text(), ltree_addltree(), ltree_addtext(), ltree_consistent(), ltree_index(), ltree_isparent(), ltree_out(), ltree_risparent(), ltree_textadd(), ltxtq_exec(), nlevel(), subltree(), and subpath().
| #define PG_GETARG_LTREE_COPY | ( | x | ) | ((ltree*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x)))) |
Definition at line 166 of file ltree.h.
Referenced by ltree_consistent().
| #define PG_GETARG_LTXTQUERY | ( | x | ) | ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) |
Definition at line 169 of file ltree.h.
Referenced by _ltxtq_exec(), _ltxtq_extract_exec(), ltxtq_exec(), and ltxtq_out().
| #define PG_GETARG_LTXTQUERY_COPY | ( | x | ) | ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x)))) |
| #define VALTRUE 6 |
Definition at line 125 of file ltree.h.
Referenced by findoprnd().
| Datum _lt_q_regex | ( | PG_FUNCTION_ARGS | ) |
Definition at line 142 of file _ltree_op.c.
References ARR_DATA_PTR, ARR_DIMS, ARR_NDIM, array_contains_nulls(), array_iterator(), ArrayGetNItems(), ereport, errcode(), errmsg(), ERROR, ltq_regex(), NEXTVAL, NULL, PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, and PG_RETURN_BOOL.
Referenced by _lt_q_rregex().
{
ArrayType *_tree = PG_GETARG_ARRAYTYPE_P(0);
ArrayType *_query = PG_GETARG_ARRAYTYPE_P(1);
lquery *query = (lquery *) ARR_DATA_PTR(_query);
bool res = false;
int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
if (ARR_NDIM(_query) > 1)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("array must be one-dimensional")));
if (array_contains_nulls(_query))
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("array must not contain nulls")));
while (num > 0)
{
if (array_iterator(_tree, ltq_regex, (void *) query, NULL))
{
res = true;
break;
}
num--;
query = (lquery *) NEXTVAL(query);
}
PG_FREE_IF_COPY(_tree, 0);
PG_FREE_IF_COPY(_query, 1);
PG_RETURN_BOOL(res);
}
| Datum _lt_q_rregex | ( | PG_FUNCTION_ARGS | ) |
Definition at line 176 of file _ltree_op.c.
References _lt_q_regex(), DirectFunctionCall2, PG_GETARG_DATUM, and PG_RETURN_DATUM.
{
PG_RETURN_DATUM(DirectFunctionCall2(_lt_q_regex,
PG_GETARG_DATUM(1),
PG_GETARG_DATUM(0)
));
}
| Datum _ltq_regex | ( | PG_FUNCTION_ARGS | ) |
Definition at line 121 of file _ltree_op.c.
References array_iterator(), ltq_regex(), NULL, PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, PG_GETARG_LQUERY, and PG_RETURN_BOOL.
Referenced by _ltq_rregex().
{
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
lquery *query = PG_GETARG_LQUERY(1);
bool res = array_iterator(la, ltq_regex, (void *) query, NULL);
PG_FREE_IF_COPY(la, 0);
PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(res);
}
| Datum _ltq_rregex | ( | PG_FUNCTION_ARGS | ) |
Definition at line 133 of file _ltree_op.c.
References _ltq_regex(), DirectFunctionCall2, PG_GETARG_DATUM, and PG_RETURN_DATUM.
{
PG_RETURN_DATUM(DirectFunctionCall2(_ltq_regex,
PG_GETARG_DATUM(1),
PG_GETARG_DATUM(0)
));
}
| Datum _ltree_isparent | ( | PG_FUNCTION_ARGS | ) |
Definition at line 79 of file _ltree_op.c.
References array_iterator(), ltree_isparent(), NULL, PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, PG_GETARG_LTREE, and PG_RETURN_BOOL.
Referenced by _ltree_r_isparent().
{
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
ltree *query = PG_GETARG_LTREE(1);
bool res = array_iterator(la, ltree_isparent, (void *) query, NULL);
PG_FREE_IF_COPY(la, 0);
PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(res);
}
| Datum _ltree_risparent | ( | PG_FUNCTION_ARGS | ) |
Definition at line 100 of file _ltree_op.c.
References array_iterator(), ltree_risparent(), NULL, PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, PG_GETARG_LTREE, and PG_RETURN_BOOL.
Referenced by _ltree_r_risparent().
{
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
ltree *query = PG_GETARG_LTREE(1);
bool res = array_iterator(la, ltree_risparent, (void *) query, NULL);
PG_FREE_IF_COPY(la, 0);
PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(res);
}
| Datum _ltxtq_exec | ( | PG_FUNCTION_ARGS | ) |
Definition at line 186 of file _ltree_op.c.
References array_iterator(), ltxtq_exec(), NULL, PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, PG_GETARG_LTXTQUERY, and PG_RETURN_BOOL.
Referenced by _ltxtq_rexec().
{
ArrayType *la = PG_GETARG_ARRAYTYPE_P(0);
ltxtquery *query = PG_GETARG_LTXTQUERY(1);
bool res = array_iterator(la, ltxtq_exec, (void *) query, NULL);
PG_FREE_IF_COPY(la, 0);
PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(res);
}
| Datum _ltxtq_rexec | ( | PG_FUNCTION_ARGS | ) |
Definition at line 198 of file _ltree_op.c.
References _ltxtq_exec(), DirectFunctionCall2, PG_GETARG_DATUM, and PG_RETURN_DATUM.
{
PG_RETURN_DATUM(DirectFunctionCall2(_ltxtq_exec,
PG_GETARG_DATUM(1),
PG_GETARG_DATUM(0)
));
}
| bool compare_subnode | ( | ltree_level * | t, | |
| char * | q, | |||
| int | len, | |||
| int(*)(const char *, const char *, size_t) | cmpptr, | |||
| bool | anyend | |||
| ) |
Definition at line 53 of file lquery_op.c.
References getlexeme(), ltree_level::len, ltree_level::name, and NULL.
Referenced by checkcondition_str(), and checkLevel().
{
char *endt = t->name + t->len;
char *endq = qn + len;
char *tn;
int lent,
lenq;
bool isok;
while ((qn = getlexeme(qn, endq, &lenq)) != NULL)
{
tn = t->name;
isok = false;
while ((tn = getlexeme(tn, endt, &lent)) != NULL)
{
if (
(
lent == lenq ||
(lent > lenq && anyend)
) &&
(*cmpptr) (qn, tn, lenq) == 0)
{
isok = true;
break;
}
tn += lent;
}
if (!isok)
return false;
qn += lenq;
}
return true;
}
Definition at line 155 of file ltree_op.c.
References ltree_level::len, LEVEL_NEXT, LTREE_FIRST, memcmp(), ltree_level::name, and ltree::numlevel.
Referenced by ltree_consistent(), ltree_isparent(), and ltree_risparent().
{
ltree_level *cl = LTREE_FIRST(c);
ltree_level *pl = LTREE_FIRST(p);
int pn = p->numlevel;
if (pn > c->numlevel)
return false;
while (pn > 0)
{
if (cl->len != pl->len)
return false;
if (memcmp(cl->name, pl->name, cl->len))
return false;
pn--;
cl = LEVEL_NEXT(cl);
pl = LEVEL_NEXT(pl);
}
return true;
}
Definition at line 425 of file ltree_op.c.
References i, LEVEL_HDRSIZE, LEVEL_NEXT, LTREE_FIRST, LTREE_HDRSIZE, MAXALIGN, memcmp(), Min, ltree::numlevel, palloc(), and SET_VARSIZE.
Referenced by _lca(), and lca().
{
int tmp,
num = ((*a)->numlevel) ? (*a)->numlevel - 1 : 0;
ltree **ptr = a + 1;
int i,
reslen = LTREE_HDRSIZE;
ltree_level *l1,
*l2;
ltree *res;
if ((*a)->numlevel == 0)
return NULL;
while (ptr - a < len)
{
if ((*ptr)->numlevel == 0)
return NULL;
else if ((*ptr)->numlevel == 1)
num = 0;
else
{
l1 = LTREE_FIRST(*a);
l2 = LTREE_FIRST(*ptr);
tmp = num;
num = 0;
for (i = 0; i < Min(tmp, (*ptr)->numlevel - 1); i++)
{
if (l1->len == l2->len && memcmp(l1->name, l2->name, l1->len) == 0)
num = i + 1;
else
break;
l1 = LEVEL_NEXT(l1);
l2 = LEVEL_NEXT(l2);
}
}
ptr++;
}
l1 = LTREE_FIRST(*a);
for (i = 0; i < num; i++)
{
reslen += MAXALIGN(l1->len + LEVEL_HDRSIZE);
l1 = LEVEL_NEXT(l1);
}
res = (ltree *) palloc(reslen);
SET_VARSIZE(res, reslen);
res->numlevel = num;
l1 = LTREE_FIRST(*a);
l2 = LTREE_FIRST(res);
for (i = 0; i < num; i++)
{
memcpy(l2, l1, MAXALIGN(l1->len + LEVEL_HDRSIZE));
l1 = LEVEL_NEXT(l1);
l2 = LEVEL_NEXT(l2);
}
return res;
}
| Datum lt_q_regex | ( | PG_FUNCTION_ARGS | ) |
Definition at line 339 of file lquery_op.c.
References ARR_DATA_PTR, ARR_DIMS, ARR_NDIM, array_contains_nulls(), ArrayGetNItems(), DatumGetBool, DirectFunctionCall2, ereport, errcode(), errmsg(), ERROR, ltq_regex(), NEXTVAL, PG_FREE_IF_COPY, PG_GETARG_ARRAYTYPE_P, PG_GETARG_LTREE, PG_RETURN_BOOL, and PointerGetDatum.
Referenced by lt_q_rregex(), and ltree_consistent().
{
ltree *tree = PG_GETARG_LTREE(0);
ArrayType *_query = PG_GETARG_ARRAYTYPE_P(1);
lquery *query = (lquery *) ARR_DATA_PTR(_query);
bool res = false;
int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
if (ARR_NDIM(_query) > 1)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("array must be one-dimensional")));
if (array_contains_nulls(_query))
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("array must not contain nulls")));
while (num > 0)
{
if (DatumGetBool(DirectFunctionCall2(ltq_regex,
PointerGetDatum(tree), PointerGetDatum(query))))
{
res = true;
break;
}
num--;
query = NEXTVAL(query);
}
PG_FREE_IF_COPY(tree, 0);
PG_FREE_IF_COPY(_query, 1);
PG_RETURN_BOOL(res);
}
| Datum lt_q_rregex | ( | PG_FUNCTION_ARGS | ) |
Definition at line 375 of file lquery_op.c.
References DirectFunctionCall2, lt_q_regex(), PG_GETARG_DATUM, and PG_RETURN_DATUM.
{
PG_RETURN_DATUM(DirectFunctionCall2(lt_q_regex,
PG_GETARG_DATUM(1),
PG_GETARG_DATUM(0)
));
}
| Datum ltq_regex | ( | PG_FUNCTION_ARGS | ) |
Definition at line 303 of file lquery_op.c.
References checkCond(), lquery::flag, LQUERY_FIRST, LQUERY_HASNOT, LTREE_FIRST, NULL, ltree::numlevel, lquery::numlevel, PG_FREE_IF_COPY, PG_GETARG_LQUERY, PG_GETARG_LTREE, PG_RETURN_BOOL, and FieldNot::q.
Referenced by _lt_q_regex(), _ltq_extract_regex(), _ltq_regex(), lt_q_regex(), ltq_rregex(), and ltree_consistent().
{
ltree *tree = PG_GETARG_LTREE(0);
lquery *query = PG_GETARG_LQUERY(1);
bool res = false;
if (query->flag & LQUERY_HASNOT)
{
FieldNot fn;
fn.q = NULL;
res = checkCond(LQUERY_FIRST(query), query->numlevel,
LTREE_FIRST(tree), tree->numlevel, &fn);
}
else
{
res = checkCond(LQUERY_FIRST(query), query->numlevel,
LTREE_FIRST(tree), tree->numlevel, NULL);
}
PG_FREE_IF_COPY(tree, 0);
PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(res);
}
| Datum ltq_rregex | ( | PG_FUNCTION_ARGS | ) |
Definition at line 330 of file lquery_op.c.
References DirectFunctionCall2, ltq_regex(), PG_GETARG_DATUM, and PG_RETURN_DATUM.
{
PG_RETURN_DATUM(DirectFunctionCall2(ltq_regex,
PG_GETARG_DATUM(1),
PG_GETARG_DATUM(0)
));
}
| Datum ltree_addltree | ( | PG_FUNCTION_ARGS | ) |
Definition at line 302 of file ltree_op.c.
References ltree_concat(), PG_FREE_IF_COPY, PG_GETARG_LTREE, and PG_RETURN_POINTER.
{
ltree *a = PG_GETARG_LTREE(0);
ltree *b = PG_GETARG_LTREE(1);
ltree *r;
r = ltree_concat(a, b);
PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b, 1);
PG_RETURN_POINTER(r);
}
| Datum ltree_addtext | ( | PG_FUNCTION_ARGS | ) |
Definition at line 315 of file ltree_op.c.
References DatumGetPointer, DirectFunctionCall1, ltree_concat(), ltree_in(), pfree(), PG_FREE_IF_COPY, PG_GETARG_LTREE, PG_GETARG_TEXT_PP, PG_RETURN_POINTER, PointerGetDatum, and text_to_cstring().
{
ltree *a = PG_GETARG_LTREE(0);
text *b = PG_GETARG_TEXT_PP(1);
char *s;
ltree *r,
*tmp;
s = text_to_cstring(b);
tmp = (ltree *) DatumGetPointer(DirectFunctionCall1(ltree_in,
PointerGetDatum(s)));
pfree(s);
r = ltree_concat(a, tmp);
pfree(tmp);
PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b, 1);
PG_RETURN_POINTER(r);
}
Definition at line 61 of file ltree_op.c.
References ltree_level::len, LEVEL_NEXT, LTREE_FIRST, memcmp(), Min, ltree_level::name, and ltree::numlevel.
Referenced by gist_ischild(), gist_isparent(), ltree_consistent(), ltree_penalty(), ltree_picksplit(), ltree_union(), and treekey_cmp().
{
ltree_level *al = LTREE_FIRST(a);
ltree_level *bl = LTREE_FIRST(b);
int an = a->numlevel;
int bn = b->numlevel;
int res = 0;
while (an > 0 && bn > 0)
{
if ((res = memcmp(al->name, bl->name, Min(al->len, bl->len))) == 0)
{
if (al->len != bl->len)
return (al->len - bl->len) * 10 * (an + 1);
}
else
return res * 10 * (an + 1);
an--;
bn--;
al = LEVEL_NEXT(al);
bl = LEVEL_NEXT(bl);
}
return (a->numlevel - b->numlevel) * 10 * (an + 1);
}
| bool ltree_execute | ( | ITEM * | curitem, | |
| void * | checkval, | |||
| bool | calcnot, | |||
| bool(*)(void *checkval, ITEM *val) | chkcond | |||
| ) |
Definition at line 19 of file ltxtquery_op.c.
References ITEM::left, ltree_execute(), ITEM::type, ITEM::val, and VAL.
Referenced by gist_qtxt(), ltree_execute(), and ltxtq_exec().
{
if (curitem->type == VAL)
return (*chkcond) (checkval, curitem);
else if (curitem->val == (int32) '!')
{
return (calcnot) ?
((ltree_execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true)
: true;
}
else if (curitem->val == (int32) '&')
{
if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
return ltree_execute(curitem + 1, checkval, calcnot, chkcond);
else
return false;
}
else
{ /* |-operator */
if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
return true;
else
return ltree_execute(curitem + 1, checkval, calcnot, chkcond);
}
}
| Datum ltree_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 44 of file ltree_io.c.
References buf, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, ISALNUM, ltree_level::len, nodeitem::len, LEVEL_HDRSIZE, LEVEL_NEXT, sort-test::list, LTPRS_WAITDELIM, LTPRS_WAITNAME, LTREE_FIRST, LTREE_HDRSIZE, MAXALIGN, ltree_level::name, ltree::numlevel, palloc(), palloc0(), pfree(), PG_GETARG_POINTER, pg_mblen(), PG_RETURN_POINTER, SET_VARSIZE, nodeitem::start, t_iseq, and nodeitem::wlen.
Referenced by ltree_addtext(), ltree_textadd(), and text2ltree().
{
char *buf = (char *) PG_GETARG_POINTER(0);
char *ptr;
nodeitem *list,
*lptr;
int num = 0,
totallen = 0;
int state = LTPRS_WAITNAME;
ltree *result;
ltree_level *curlevel;
int charlen;
int pos = 0;
ptr = buf;
while (*ptr)
{
charlen = pg_mblen(ptr);
if (charlen == 1 && t_iseq(ptr, '.'))
num++;
ptr += charlen;
}
list = lptr = (nodeitem *) palloc(sizeof(nodeitem) * (num + 1));
ptr = buf;
while (*ptr)
{
charlen = pg_mblen(ptr);
if (state == LTPRS_WAITNAME)
{
if (ISALNUM(ptr))
{
lptr->start = ptr;
lptr->wlen = 0;
state = LTPRS_WAITDELIM;
}
else
UNCHAR;
}
else if (state == LTPRS_WAITDELIM)
{
if (charlen == 1 && t_iseq(ptr, '.'))
{
lptr->len = ptr - lptr->start;
if (lptr->wlen > 255)
ereport(ERROR,
(errcode(ERRCODE_NAME_TOO_LONG),
errmsg("name of level is too long"),
errdetail("Name length is %d, must "
"be < 256, in position %d.",
lptr->wlen, pos)));
totallen += MAXALIGN(lptr->len + LEVEL_HDRSIZE);
lptr++;
state = LTPRS_WAITNAME;
}
else if (!ISALNUM(ptr))
UNCHAR;
}
else
/* internal error */
elog(ERROR, "internal error in parser");
ptr += charlen;
lptr->wlen++;
pos++;
}
if (state == LTPRS_WAITDELIM)
{
lptr->len = ptr - lptr->start;
if (lptr->wlen > 255)
ereport(ERROR,
(errcode(ERRCODE_NAME_TOO_LONG),
errmsg("name of level is too long"),
errdetail("Name length is %d, must "
"be < 256, in position %d.",
lptr->wlen, pos)));
totallen += MAXALIGN(lptr->len + LEVEL_HDRSIZE);
lptr++;
}
else if (!(state == LTPRS_WAITNAME && lptr == list))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error"),
errdetail("Unexpected end of line.")));
result = (ltree *) palloc0(LTREE_HDRSIZE + totallen);
SET_VARSIZE(result, LTREE_HDRSIZE + totallen);
result->numlevel = lptr - list;
curlevel = LTREE_FIRST(result);
lptr = list;
while (lptr - list < result->numlevel)
{
curlevel->len = (uint16) lptr->len;
memcpy(curlevel->name, lptr->start, lptr->len);
curlevel = LEVEL_NEXT(curlevel);
lptr++;
}
pfree(list);
PG_RETURN_POINTER(result);
}
| Datum ltree_isparent | ( | PG_FUNCTION_ARGS | ) |
Definition at line 179 of file ltree_op.c.
References inner_isparent(), PG_FREE_IF_COPY, PG_GETARG_LTREE, and PG_RETURN_BOOL.
Referenced by _ltree_extract_isparent(), and _ltree_isparent().
{
ltree *c = PG_GETARG_LTREE(1);
ltree *p = PG_GETARG_LTREE(0);
bool res = inner_isparent(c, p);
PG_FREE_IF_COPY(c, 1);
PG_FREE_IF_COPY(p, 0);
PG_RETURN_BOOL(res);
}
| Datum ltree_risparent | ( | PG_FUNCTION_ARGS | ) |
Definition at line 191 of file ltree_op.c.
References inner_isparent(), PG_FREE_IF_COPY, PG_GETARG_LTREE, and PG_RETURN_BOOL.
Referenced by _ltree_extract_risparent(), and _ltree_risparent().
{
ltree *c = PG_GETARG_LTREE(0);
ltree *p = PG_GETARG_LTREE(1);
bool res = inner_isparent(c, p);
PG_FREE_IF_COPY(c, 0);
PG_FREE_IF_COPY(p, 1);
PG_RETURN_BOOL(res);
}
| int ltree_strncasecmp | ( | const char * | a, | |
| const char * | b, | |||
| size_t | s | |||
| ) |
Definition at line 91 of file lquery_op.c.
References DEFAULT_COLLATION_OID, pfree(), and str_tolower().
Referenced by checkcondition_str(), and checkLevel().
{
char *al = str_tolower(a, s, DEFAULT_COLLATION_OID);
char *bl = str_tolower(b, s, DEFAULT_COLLATION_OID);
int res;
res = strncmp(al, bl, s);
pfree(al);
pfree(bl);
return res;
}
| Datum ltree_textadd | ( | PG_FUNCTION_ARGS | ) |
Definition at line 400 of file ltree_op.c.
References DatumGetPointer, DirectFunctionCall1, ltree_concat(), ltree_in(), pfree(), PG_FREE_IF_COPY, PG_GETARG_LTREE, PG_GETARG_TEXT_PP, PG_RETURN_POINTER, PointerGetDatum, and text_to_cstring().
{
ltree *a = PG_GETARG_LTREE(1);
text *b = PG_GETARG_TEXT_PP(0);
char *s;
ltree *r,
*tmp;
s = text_to_cstring(b);
tmp = (ltree *) DatumGetPointer(DirectFunctionCall1(ltree_in,
PointerGetDatum(s)));
pfree(s);
r = ltree_concat(tmp, a);
pfree(tmp);
PG_FREE_IF_COPY(a, 1);
PG_FREE_IF_COPY(b, 0);
PG_RETURN_POINTER(r);
}
| Datum ltxtq_exec | ( | PG_FUNCTION_ARGS | ) |
Definition at line 83 of file ltxtquery_op.c.
References checkcondition_str(), GETOPERAND, GETQUERY, ltree_execute(), CHKVAL::node, CHKVAL::operand, PG_FREE_IF_COPY, PG_GETARG_LTREE, PG_GETARG_LTXTQUERY, PG_RETURN_BOOL, and val.
Referenced by _ltxtq_exec(), _ltxtq_extract_exec(), ltree_consistent(), and ltxtq_rexec().
{
ltree *val = PG_GETARG_LTREE(0);
ltxtquery *query = PG_GETARG_LTXTQUERY(1);
CHKVAL chkval;
bool result;
chkval.node = val;
chkval.operand = GETOPERAND(query);
result = ltree_execute(
GETQUERY(query),
&chkval,
true,
checkcondition_str
);
PG_FREE_IF_COPY(val, 0);
PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(result);
}
| Datum ltxtq_rexec | ( | PG_FUNCTION_ARGS | ) |
Definition at line 106 of file ltxtquery_op.c.
References DirectFunctionCall2, ltxtq_exec(), PG_GETARG_DATUM, and PG_RETURN_DATUM.
{
PG_RETURN_DATUM(DirectFunctionCall2(ltxtq_exec,
PG_GETARG_DATUM(1),
PG_GETARG_DATUM(0)
));
}
1.7.1