QueryItem *first_item;
GinTernaryValue *check;
int *map_item_operand;
- bool *need_recheck;
} GinChkVal;
/*
{
GinChkVal *gcv = (GinChkVal *) checkval;
int j;
-
- /*
- * if any val requiring a weight is used or caller needs position
- * information then set recheck flag
- */
- if (val->weight != 0 || data != NULL)
- *(gcv->need_recheck) = true;
+ GinTernaryValue result;
/* convert item's number to corresponding entry's (operand's) number */
j = gcv->map_item_operand[((QueryItem *) val) - gcv->first_item];
+ /* determine presence of current entry in indexed value */
+ result = gcv->check[j];
+
/*
- * return presence of current entry in indexed value; but TRUE becomes
- * MAYBE in the presence of a query requiring recheck
+ * If any val requiring a weight is used or caller needs position
+ * information then we must recheck, so replace TRUE with MAYBE.
*/
- if (gcv->check[j] == GIN_TRUE)
+ if (result == GIN_TRUE)
{
if (val->weight != 0 || data != NULL)
- return TS_MAYBE;
+ result = GIN_MAYBE;
}
/*
* assignments. We could use a switch statement to map the values if that
* ever stops being true, but it seems unlikely to happen.
*/
- return (TSTernaryValue) gcv->check[j];
+ return (TSTernaryValue) result;
}
Datum
"sizes of GinTernaryValue and bool are not equal");
gcv.check = (GinTernaryValue *) check;
gcv.map_item_operand = (int *) (extra_data[0]);
- gcv.need_recheck = recheck;
- res = TS_execute(GETQUERY(query),
- &gcv,
- TS_EXEC_PHRASE_NO_POS,
- checkcondition_gin);
+ switch (TS_execute_ternary(GETQUERY(query),
+ &gcv,
+ TS_EXEC_PHRASE_NO_POS,
+ checkcondition_gin))
+ {
+ case TS_NO:
+ res = false;
+ break;
+ case TS_YES:
+ res = true;
+ break;
+ case TS_MAYBE:
+ res = true;
+ *recheck = true;
+ break;
+ }
}
PG_RETURN_BOOL(res);
/* int32 nkeys = PG_GETARG_INT32(3); */
Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_FALSE;
- bool recheck;
-
- /* Initially assume query doesn't require recheck */
- recheck = false;
if (query->size > 0)
{
gcv.first_item = GETQUERY(query);
gcv.check = check;
gcv.map_item_operand = (int *) (extra_data[0]);
- gcv.need_recheck = &recheck;
- if (TS_execute(GETQUERY(query),
- &gcv,
- TS_EXEC_PHRASE_NO_POS,
- checkcondition_gin))
- res = recheck ? GIN_MAYBE : GIN_TRUE;
+ res = TS_execute_ternary(GETQUERY(query),
+ &gcv,
+ TS_EXEC_PHRASE_NO_POS,
+ checkcondition_gin);
}
PG_RETURN_GIN_TERNARY_VALUE(res);
return TS_execute_recurse(curitem, arg, flags, chkcond) != TS_NO;
}
+/*
+ * Evaluate tsquery boolean expression.
+ *
+ * This is the same as TS_execute except that TS_MAYBE is returned as-is.
+ */
+TSTernaryValue
+TS_execute_ternary(QueryItem *curitem, void *arg, uint32 flags,
+ TSExecuteCallback chkcond)
+{
+ return TS_execute_recurse(curitem, arg, flags, chkcond);
+}
+
/*
* TS_execute recursion for operators above any phrase operator. Here we do
* not need to worry about lexeme positions. As soon as we hit an OP_PHRASE