MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / execute_with_clause

Function execute_with_clause

src/cypher/cypher.c:3759–3803  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3757}
3758
3759static void execute_with_clause(cbm_query_t *q, binding_t **bindings_ptr, int *bind_count_ptr) {
3760 cbm_return_clause_t *wc = q->with_clause;
3761 if (!wc) {
3762 return;
3763 }
3764 binding_t *bindings = *bindings_ptr;
3765 int bind_count = *bind_count_ptr;
3766
3767 binding_t *vbindings = malloc((bind_count + SKIP_ONE) * sizeof(binding_t));
3768 int vcount = 0;
3769
3770 bool has_agg = false;
3771 for (int i = 0; i < wc->count; i++) {
3772 if (is_aggregate_func(wc->items[i].func)) {
3773 has_agg = true;
3774 break;
3775 }
3776 }
3777
3778 if (has_agg) {
3779 execute_with_aggregate(wc, bindings, bind_count, &vbindings, &vcount);
3780 } else {
3781 execute_with_simple(wc, bindings, bind_count, vbindings, &vcount);
3782 }
3783
3784 /* WITH DISTINCT: dedup projected rows (no-op for aggregation, which already
3785 * collapses to one row per group). */
3786 if (wc->distinct) {
3787 with_apply_distinct(wc, vbindings, &vcount);
3788 }
3789
3790 with_sort_skip_limit(wc, vbindings, &vcount);
3791
3792 for (int bi = 0; bi < bind_count; bi++) {
3793 binding_free(&bindings[bi]);
3794 }
3795 free(bindings);
3796
3797 if (q->post_with_where) {
3798 filter_bindings_where(q->post_with_where, vbindings, &vcount);
3799 }
3800
3801 *bindings_ptr = vbindings;
3802 *bind_count_ptr = vcount;
3803}
3804
3805/* ── Execute a single query (no UNION recursion) ──────────────── */
3806

Callers 1

execute_singleFunction · 0.85

Calls 7

is_aggregate_funcFunction · 0.85
execute_with_aggregateFunction · 0.85
execute_with_simpleFunction · 0.85
with_apply_distinctFunction · 0.85
with_sort_skip_limitFunction · 0.85
binding_freeFunction · 0.85
filter_bindings_whereFunction · 0.85

Tested by

no test coverage detected