Predicate evaluation — PRED_EXPR + REGU_VARIABLE
The same evaluator runs at every site that needs "does this tuple match?" — scan filters, join conditions, post-processing.
PRED_EXPR tree. Two leaf kinds: T_PRED (boolean operator: AND, OR, NOT) and T_EVAL_TERM (leaf comparison: x = y, a < b, s LIKE p).
REGU_VARIABLE operands. Resolves to: a constant, a column reference, an arithmetic expression (via qdata_*), a function call, or a host parameter.
- Three-valued logic.
TRUE / FALSE / UNKNOWN; Kleene's rules — TRUE AND UNKNOWN = UNKNOWN, FALSE AND UNKNOWN = FALSE.
DB_LOGICAL eval_pred (THREAD_ENTRY *th, PRED_EXPR *p, VAL_DESCR *vd, OID *o)
{
switch (p->type)
{
case T_PRED: return pred_combine (eval_pred (p->lhs), eval_pred (p->rhs), p->op);
case T_EVAL_TERM: return eval_term (th, &p->term, vd, o);
case T_NOT_TERM: return v_not (eval_pred (p->child));
}
}
One evaluator, four call sites: key_pred (index), where_pred (scan), merge_pred/inner_pred (join), post-processing.