19 #include "utils/fmgrprotos.h"
26 int nnode = query->
size;
41 res->valnode->qoperator.oper =
operator;
43 res->valnode->qoperator.distance = distance;
66 else if (
b->size == 0)
96 else if (
b->size == 0)
124 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
125 errmsg(
"distance in phrase operator must be an integer value between zero and %d inclusive",
132 else if (
b->size == 0)
191 if (
a->size !=
b->size)
193 return (
a->size <
b->size) ? -1 : 1;
199 else if (
a->size != 0)
227 #define CMPFUNC( NAME, CONDITION ) \
229 NAME(PG_FUNCTION_ARGS) { \
230 TSQuery a = PG_GETARG_TSQUERY_COPY(0); \
231 TSQuery b = PG_GETARG_TSQUERY_COPY(1); \
232 int res = CompareTSQ(a,b); \
234 PG_FREE_IF_COPY(a,0); \
235 PG_FREE_IF_COPY(b,1); \
237 PG_RETURN_BOOL( CONDITION ); \
240 extern int no_such_variable
256 for (
i = 0;
i <
a->size;
i++)
277 for (
i = 0;
i <
a->size;
i++)
293 *nvalues_p = nvalues;
300 const char *
sa = *((
char *
const *)
a);
301 const char *sb = *((
char *
const *)
b);
303 return strcmp(
sa, sb);
323 query_nvalues =
qunique(query_values, query_nvalues,
sizeof(
char *),
328 if (ex_nvalues > query_nvalues)
335 for (
i = 0;
i < ex_nvalues;
i++)
337 for (;
j < query_nvalues;
j++)
339 if (strcmp(ex_values[
i], query_values[
j]) == 0)
342 if (
j == query_nvalues)
static Datum values[MAXATTR]
static void PGresult * res
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_FREE_IF_COPY(ptr, n)
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_DATUM(n)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_RETURN_DATUM(x)
#define DirectFunctionCall3(func, arg1, arg2, arg3)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
void * palloc0(Size size)
#define qsort(a, b, c, d)
static Datum Int32GetDatum(int32 X)
static size_t qunique(void *array, size_t elements, size_t width, int(*compare)(const void *, const void *))
#define PG_GETARG_TSQUERY(n)
#define PG_RETURN_TSQUERY(x)
#define PG_GETARG_TSQUERY_COPY(n)
Datum tsq_mcontains(PG_FUNCTION_ARGS)
static char ** collectTSQueryValues(TSQuery a, int *nvalues_p)
Datum tsquery_numnode(PG_FUNCTION_ARGS)
Datum tsquery_and(PG_FUNCTION_ARGS)
Datum tsq_mcontained(PG_FUNCTION_ARGS)
TSQuerySign makeTSQuerySign(TSQuery a)
static int cmp_string(const void *a, const void *b)
Datum tsquery_not(PG_FUNCTION_ARGS)
Datum tsquery_or(PG_FUNCTION_ARGS)
static int CompareTSQ(TSQuery a, TSQuery b)
static QTNode * join_tsqueries(TSQuery a, TSQuery b, int8 operator, uint16 distance)
Datum tsquery_phrase(PG_FUNCTION_ARGS)
Datum tsquery_phrase_distance(PG_FUNCTION_ARGS)
Datum tsquery_cmp(PG_FUNCTION_ARGS)
#define CMPFUNC(NAME, CONDITION)
int QTNodeCompare(QTNode *an, QTNode *bn)
QTNode * QT2QTN(QueryItem *in, char *operand)
TSQuery QTN2QT(QTNode *in)