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. */
| 5018 | * (f)-[:CALLS]->(g)` names f in two patterns and f gets its four columns |
| 5019 | * twice. */ |
| 5020 | static 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 */ |
| 5040 | static void build_star_columns(result_builder_t *rb, const char **vars, int vc) { |
no test coverage detected