Datum
tsquery_phrase_distance(PG_FUNCTION_ARGS)
{
TSQuery a = PG_GETARG_TSQUERY_COPY(0);
TSQuery b = PG_GETARG_TSQUERY_COPY(1);
QTNode *res;
TSQuery query;
int32 distance = PG_GETARG_INT32(2);
if (distance < 0 || distance > MAXENTRYPOS)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("distance in phrase operator must be an integer value between zero and %d inclusive",
MAXENTRYPOS))); if (a->size == 0)
{
PG_FREE_IF_COPY(a, 1);
PG_RETURN_POINTER(b);
} elseif (b->size == 0)
{
PG_FREE_IF_COPY(b, 1);
PG_RETURN_POINTER(a);
}
res = join_tsqueries(a, b, OP_PHRASE, (uint16) distance);
Datum
tsquery_cmp(PG_FUNCTION_ARGS)
{
TSQuery a = PG_GETARG_TSQUERY_COPY(0);
TSQuery b = PG_GETARG_TSQUERY_COPY(1); int res = CompareTSQ(a, b);
PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b, 1);
PG_RETURN_INT32(res);
}
#define CMPFUNC( NAME, CONDITION ) \
Datum \
NAME(PG_FUNCTION_ARGS) { \
TSQuery a = PG_GETARG_TSQUERY_COPY(0); \
TSQuery b = PG_GETARG_TSQUERY_COPY(1); \ int res = CompareTSQ(a,b); \
\
PG_FREE_IF_COPY(a,0); \
PG_FREE_IF_COPY(b,1); \
\
PG_RETURN_BOOL( CONDITION ); \
} \ /* keep compiler quiet - no extra ; */ \ externint no_such_variable
CMPFUNC(tsquery_lt, res < 0);
CMPFUNC(tsquery_le, res <= 0);
CMPFUNC(tsquery_eq, res == 0);
CMPFUNC(tsquery_ge, res >= 0);
CMPFUNC(tsquery_gt, res > 0);
CMPFUNC(tsquery_ne, res != 0);
TSQuerySign
makeTSQuerySign(TSQuery a)
{ int i;
QueryItem *ptr = GETQUERY(a);
TSQuerySign sign = 0;
for (i = 0; i < a->size; i++)
{ if (ptr->type == QI_VAL)
sign |= ((TSQuerySign) 1) << (((unsignedint) ptr->qoperand.valcrc) % TSQS_SIGLEN);
ptr++;
}
return sign;
}
staticchar **
collectTSQueryValues(TSQuery a, int *nvalues_p)
{
QueryItem *ptr = GETQUERY(a); char *operand = GETOPERAND(a); char **values; int nvalues = 0; int i;
Datum
tsq_mcontains(PG_FUNCTION_ARGS)
{
TSQuery query = PG_GETARG_TSQUERY(0);
TSQuery ex = PG_GETARG_TSQUERY(1); char **query_values; int query_nvalues; char **ex_values; int ex_nvalues; bool result = true;
/* Extract the query terms into arrays */
query_values = collectTSQueryValues(query, &query_nvalues);
ex_values = collectTSQueryValues(ex, &ex_nvalues);
if (ex_nvalues > query_nvalues)
result = false; else
{ int i; int j = 0;
for (i = 0; i < ex_nvalues; i++)
{ for (; j < query_nvalues; j++)
{ if (strcmp(ex_values[i], query_values[j]) == 0) break;
} if (j == query_nvalues)
{
result = false; break;
}
}
}
PG_RETURN_BOOL(result);
}
Datum
tsq_mcontained(PG_FUNCTION_ARGS)
{
PG_RETURN_DATUM(DirectFunctionCall2(tsq_mcontains,
PG_GETARG_DATUM(1),
PG_GETARG_DATUM(0)));
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.13Bemerkung:
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.