PostgreSQL Source Code git master
Loading...
Searching...
No Matches
ltxtquery_op.c File Reference
#include "postgres.h"
#include <ctype.h>
#include "ltree.h"
#include "miscadmin.h"
Include dependency graph for ltxtquery_op.c:

Go to the source code of this file.

Data Structures

struct  CHKVAL
 

Functions

 PG_FUNCTION_INFO_V1 (ltxtq_exec)
 
 PG_FUNCTION_INFO_V1 (ltxtq_rexec)
 
bool ltree_execute (ITEM *curitem, void *checkval, bool calcnot, bool(*chkcond)(void *checkval, ITEM *val))
 
static bool checkcondition_str (void *checkval, ITEM *val)
 
Datum ltxtq_exec (PG_FUNCTION_ARGS)
 
Datum ltxtq_rexec (PG_FUNCTION_ARGS)
 

Function Documentation

◆ checkcondition_str()

static bool checkcondition_str ( void checkval,
ITEM val 
)
static

Definition at line 56 of file ltxtquery_op.c.

57{
58 ltree_level *level = LTREE_FIRST(((CHKVAL *) checkval)->node);
59 int tlen = ((CHKVAL *) checkval)->node->numlevel;
60 char *op = ((CHKVAL *) checkval)->operand + val->distance;
61 bool prefix = (val->flag & LVAR_ANYEND);
62 bool ci = (val->flag & LVAR_INCASE);
63
64 while (tlen > 0)
65 {
66 if (val->flag & LVAR_SUBLEXEME)
67 {
68 if (compare_subnode(level, op, val->length, prefix, ci))
69 return true;
70 }
71 else if (ltree_label_match(op, val->length, level->name, level->len,
72 prefix, ci))
73 return true;
74
75 tlen--;
76 level = LEVEL_NEXT(level);
77 }
78
79 return false;
80}
long val
Definition informix.c:689
bool compare_subnode(ltree_level *t, char *qn, int len, bool prefix, bool ci)
Definition lquery_op.c:44
bool ltree_label_match(const char *pred, size_t pred_len, const char *label, size_t label_len, bool prefix, bool ci)
Definition lquery_op.c:81
#define LTREE_FIRST(x)
Definition ltree.h:51
#define LVAR_INCASE
Definition ltree.h:75
#define LEVEL_NEXT(x)
Definition ltree.h:40
#define LVAR_ANYEND
Definition ltree.h:74
#define LVAR_SUBLEXEME
Definition ltree.h:76
static int fb(int x)
char name[FLEXIBLE_ARRAY_MEMBER]
Definition ltree.h:36
uint16 len
Definition ltree.h:35

References compare_subnode(), fb(), ltree_level::len, LEVEL_NEXT, LTREE_FIRST, ltree_label_match(), LVAR_ANYEND, LVAR_INCASE, LVAR_SUBLEXEME, ltree_level::name, and val.

Referenced by ltxtq_exec().

◆ ltree_execute()

bool ltree_execute ( ITEM curitem,
void checkval,
bool  calcnot,
bool(*)(void *checkval, ITEM *val chkcond 
)

Definition at line 20 of file ltxtquery_op.c.

21{
22 /* since this function recurses, it could be driven to stack overflow */
24
25 if (curitem->type == VAL)
26 return (*chkcond) (checkval, curitem);
27 else if (curitem->val == (int32) '!')
28 {
29 return calcnot ?
30 ((ltree_execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true)
31 : true;
32 }
33 else if (curitem->val == (int32) '&')
34 {
35 if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
36 return ltree_execute(curitem + 1, checkval, calcnot, chkcond);
37 else
38 return false;
39 }
40 else
41 { /* |-operator */
42 if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
43 return true;
44 else
45 return ltree_execute(curitem + 1, checkval, calcnot, chkcond);
46 }
47}
#define VAL
Definition _int.h:162
int32_t int32
Definition c.h:575
return true
Definition isn.c:130
bool ltree_execute(ITEM *curitem, void *checkval, bool calcnot, bool(*chkcond)(void *checkval, ITEM *val))
void check_stack_depth(void)
Definition stack_depth.c:95
int16 left
Definition _int.h:143
int32 val
Definition _int.h:144
int16 type
Definition _int.h:142

References check_stack_depth(), fb(), ITEM::left, ltree_execute(), ITEM::type, ITEM::val, and VAL.

Referenced by gist_qtxt(), gist_qtxt(), ltree_execute(), and ltxtq_exec().

◆ ltxtq_exec()

Datum ltxtq_exec ( PG_FUNCTION_ARGS  )

Definition at line 83 of file ltxtquery_op.c.

84{
88 bool result;
89
90 chkval.node = val;
91 chkval.operand = GETOPERAND(query);
92
93 result = ltree_execute(GETQUERY(query),
94 &chkval,
95 true,
97
99 PG_FREE_IF_COPY(query, 1);
100 PG_RETURN_BOOL(result);
101}
#define GETQUERY(x)
Definition _int.h:157
#define PG_FREE_IF_COPY(ptr, n)
Definition fmgr.h:260
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360
#define PG_GETARG_LTXTQUERY_P(n)
Definition ltree.h:229
#define GETOPERAND(x)
Definition ltree.h:165
#define PG_GETARG_LTREE_P(n)
Definition ltree.h:219
static bool checkcondition_str(void *checkval, ITEM *val)
ltree * node
Definition ltree.h:43

References checkcondition_str(), fb(), GETOPERAND, GETQUERY, ltree_execute(), CHKVAL::node, PG_FREE_IF_COPY, PG_GETARG_LTREE_P, PG_GETARG_LTXTQUERY_P, PG_RETURN_BOOL, and val.

Referenced by _ltxtq_exec(), _ltxtq_extract_exec(), ltree_consistent(), and ltxtq_rexec().

◆ ltxtq_rexec()

Datum ltxtq_rexec ( PG_FUNCTION_ARGS  )

Definition at line 104 of file ltxtquery_op.c.

105{
109 ));
110}
#define DirectFunctionCall2(func, arg1, arg2)
Definition fmgr.h:686
#define PG_GETARG_DATUM(n)
Definition fmgr.h:268
#define PG_RETURN_DATUM(x)
Definition fmgr.h:354
Datum ltxtq_exec(PG_FUNCTION_ARGS)

References DirectFunctionCall2, ltxtq_exec(), PG_GETARG_DATUM, and PG_RETURN_DATUM.

◆ PG_FUNCTION_INFO_V1() [1/2]

PG_FUNCTION_INFO_V1 ( ltxtq_exec  )

◆ PG_FUNCTION_INFO_V1() [2/2]

PG_FUNCTION_INFO_V1 ( ltxtq_rexec  )