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

Function parse_order_by_clause

src/cypher/cypher.c:1734–1753  ·  view source on GitHub ↗

Parse the full comma-separated ORDER BY key list (#1334). Consuming only the * first key left ", key2 ... LIMIT n" unparsed, which silently dropped the * LIMIT and flooded the caller with the whole result set. Returns 0 on * success, CBM_NOT_FOUND when the key list exceeds the modeled maximum. */

Source from the content-addressed store, hash-verified

1732 * LIMIT and flooded the caller with the whole result set. Returns 0 on
1733 * success, CBM_NOT_FOUND when the key list exceeds the modeled maximum. */
1734static int parse_order_by_clause(parser_t *p, cbm_return_clause_t *r) {
1735 expect(p, TOK_BY);
1736 do {
1737 if (r->order_key_count >= CBM_CYPHER_ORDER_KEYS_MAX) {
1738 return CBM_NOT_FOUND;
1739 }
1740 char order_buf[CBM_SZ_256];
1741 parse_order_by_expr(p, order_buf, sizeof(order_buf));
1742 bool desc = false;
1743 if (match(p, TOK_ASC)) {
1744 desc = false;
1745 } else if (match(p, TOK_DESC)) {
1746 desc = true;
1747 }
1748 r->order_keys[r->order_key_count] = heap_strdup(order_buf);
1749 r->order_descs[r->order_key_count] = desc;
1750 r->order_key_count++;
1751 } while (match(p, TOK_COMMA));
1752 return 0;
1753}
1754
1755static void free_return_clause(cbm_return_clause_t *r);
1756

Callers 1

parse_return_or_withFunction · 0.85

Calls 4

expectFunction · 0.85
parse_order_by_exprFunction · 0.85
matchFunction · 0.85
heap_strdupFunction · 0.70

Tested by

no test coverage detected