Skip to content

Commit 43a7e59

Browse files
committed
revert(cypher): drop the early-WHERE deferral that DeusData#2253 superseded
The early WHERE pass in execute_single runs on seed rows where only the first alias is bound, so a NOT on the target node or the relationship pruned every row (DeusData#2250). This branch fixed that by skipping the early pass until every alias the WHERE reads was bound. While it waited for review, DeusData#2253 (8ab555e) landed the same fix on main as a three-valued early pass: an unbound alias is UNKNOWN, NOT keeps it UNKNOWN, and only a definite FALSE prunes. This branch's regression tests pass on main's production code unchanged, so restore src/cypher/cypher.c to the branch's base and keep the tests; the merge of main that follows takes main's implementation. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 937ad47 commit 43a7e59

1 file changed

Lines changed: 2 additions & 50 deletions

File tree

‎src/cypher/cypher.c‎

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4145,54 +4145,7 @@ static void execute_with_simple(cbm_return_clause_t *wc, binding_t *bindings, in
41454145
}
41464146
}
41474147

4148-
static bool condition_bindings_available(const cbm_condition_t *condition, binding_t *binding) {
4149-
if (condition->variable && !binding_get(binding, condition->variable) &&
4150-
!binding_get_edge(binding, condition->variable)) {
4151-
return false;
4152-
}
4153-
for (int i = 0; i < condition->arg_count; i++) {
4154-
const char *var = condition->args[i].variable;
4155-
if (var && !binding_get(binding, var) && !binding_get_edge(binding, var)) {
4156-
return false;
4157-
}
4158-
}
4159-
return true;
4160-
}
4161-
4162-
static bool expr_bindings_available(const cbm_expr_t *expr, binding_t *binding) {
4163-
if (!expr) {
4164-
return true;
4165-
}
4166-
switch (expr->type) {
4167-
case EXPR_CONDITION:
4168-
return condition_bindings_available(&expr->cond, binding);
4169-
case EXPR_AND:
4170-
case EXPR_OR:
4171-
case EXPR_XOR:
4172-
return expr_bindings_available(expr->left, binding) &&
4173-
expr_bindings_available(expr->right, binding);
4174-
case EXPR_NOT:
4175-
return expr_bindings_available(expr->left, binding);
4176-
}
4177-
return false;
4178-
}
4179-
4180-
static bool where_bindings_available(const cbm_where_clause_t *where, binding_t *binding) {
4181-
if (!where) {
4182-
return true;
4183-
}
4184-
if (where->root) {
4185-
return expr_bindings_available(where->root, binding);
4186-
}
4187-
for (int i = 0; i < where->count; i++) {
4188-
if (!condition_bindings_available(&where->conditions[i], binding)) {
4189-
return false;
4190-
}
4191-
}
4192-
return true;
4193-
}
4194-
4195-
/* Apply a WHERE filter after its referenced variables have been bound. */
4148+
/* Apply post-WITH WHERE filter */
41964149
static void filter_bindings_where(const cbm_where_clause_t *where, binding_t *vbindings,
41974150
int *vcount) {
41984151
int kept = 0;
@@ -5196,8 +5149,7 @@ static int execute_single(cbm_store_t *store, cbm_query_t *q, const char *projec
51965149
binding_t b = {0};
51975150
b.store = store;
51985151
binding_set(&b, var_name, &scanned[i]);
5199-
bool pass = !q->where || !where_bindings_available(q->where, &b) ||
5200-
eval_where(q->where, &b);
5152+
bool pass = !q->where || eval_where(q->where, &b);
52015153
if (pass) {
52025154
bindings[bind_count++] = b;
52035155
} else {

0 commit comments

Comments
 (0)