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

Function collect_pattern_vars

src/cypher/cypher.c:5020–5037  ·  view source on GitHub ↗

Collect the variables a RETURN * projects, in the order the query names them * and with no repeats. Without the repeat check, `MATCH (f) OPTIONAL MATCH * (f)-[:CALLS]->(g)` names f in two patterns and f gets its four columns * twice. */

Source from the content-addressed store, hash-verified

5018 * (f)-[:CALLS]->(g)` names f in two patterns and f gets its four columns
5019 * twice. */
5020static int collect_pattern_vars(cbm_query_t *q, const char **vars, int max_vars) {
5021 int vc = 0;
5022 for (int pi = 0; pi < q->pattern_count; pi++) {
5023 for (int ni = 0; ni < q->patterns[pi].node_count && vc < max_vars; ni++) {
5024 const char *var = q->patterns[pi].nodes[ni].variable;
5025 if (var && !star_var_seen(vars, vc, var)) {
5026 vars[vc++] = var;
5027 }
5028 }
5029 for (int ri = 0; ri < q->patterns[pi].rel_count && vc < max_vars; ri++) {
5030 const char *var = q->patterns[pi].rels[ri].variable;
5031 if (var && !star_var_seen(vars, vc, var)) {
5032 vars[vc++] = var;
5033 }
5034 }
5035 }
5036 return vc;
5037}
5038
5039/* Build star-projection columns: var.name, var.qualified_name, var.label, var.file_path */
5040static void build_star_columns(result_builder_t *rb, const char **vars, int vc) {

Callers 1

ret_sink_init_starFunction · 0.85

Calls 1

star_var_seenFunction · 0.85

Tested by

no test coverage detected