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

Function execute_with_clause

src/cypher/cypher.c:4104–4148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4102}
4103
4104static void execute_with_clause(cbm_query_t *q, binding_t **bindings_ptr, int *bind_count_ptr) {
4105 cbm_return_clause_t *wc = q->with_clause;
4106 if (!wc) {
4107 return;
4108 }
4109 binding_t *bindings = *bindings_ptr;
4110 int bind_count = *bind_count_ptr;
4111
4112 binding_t *vbindings = malloc((bind_count + SKIP_ONE) * sizeof(binding_t));
4113 int vcount = 0;
4114
4115 bool has_agg = false;
4116 for (int i = 0; i < wc->count; i++) {
4117 if (is_aggregate_func(wc->items[i].func)) {
4118 has_agg = true;
4119 break;
4120 }
4121 }
4122
4123 if (has_agg) {
4124 execute_with_aggregate(wc, bindings, bind_count, &vbindings, &vcount);
4125 } else {
4126 execute_with_simple(wc, bindings, bind_count, vbindings, &vcount);
4127 }
4128
4129 /* WITH DISTINCT: dedup projected rows (no-op for aggregation, which already
4130 * collapses to one row per group). */
4131 if (wc->distinct) {
4132 with_apply_distinct(wc, vbindings, &vcount);
4133 }
4134
4135 with_sort_skip_limit(wc, vbindings, &vcount);
4136
4137 for (int bi = 0; bi < bind_count; bi++) {
4138 binding_free(&bindings[bi]);
4139 }
4140 free(bindings);
4141
4142 if (q->post_with_where) {
4143 filter_bindings_where(q->post_with_where, vbindings, &vcount);
4144 }
4145
4146 *bindings_ptr = vbindings;
4147 *bind_count_ptr = vcount;
4148}
4149
4150/* ── Execute a single query (no UNION recursion) ──────────────── */
4151

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