diff --git a/docs/testing/semantic-coverage-matrix.md b/docs/testing/semantic-coverage-matrix.md index 08b021d..a30b672 100644 --- a/docs/testing/semantic-coverage-matrix.md +++ b/docs/testing/semantic-coverage-matrix.md @@ -385,3 +385,17 @@ unit 944/944; functional clean): Added a mirror rule chaining four `make_label_expr` conjuncts. Repeated labels are harmless — each conjunct is an independent EXISTS check. No bison conflicts (still `%expect 15` / `%expect-rr 3`). + +## Coverage update (2026-05-28) — existential subquery brace form (no inner WHERE) + +`cypher_gram.y`. Verified via the TCK harness (3708 -> 3710, zero regressions; +unit 944/944; functional clean): + +- **`WHERE exists { (n)-->() }` parses and evaluates** (ExistentialSubquery1 + [1]/[3]). Added `EXISTS '{' pattern_list '}'` reusing the existing + `EXISTS_TYPE_PATTERN` transform, which already resolves correlated outer + variables (the bound `n`) via its outer-alias lookup and emits a correlated + `EXISTS (SELECT 1 FROM ... WHERE ...)` subquery. No bison conflicts (still + `%expect 15` / `%expect-rr 3`). The brace form **with** an inner `WHERE` + ([2]/[4]) and the full-query/aggregation/nested forms (ExistentialSubquery2/3) + remain unsupported — they need inner-variable registration and are deferred. diff --git a/src/backend/parser/cypher_gram.y b/src/backend/parser/cypher_gram.y index 1199ffd..924f6ac 100644 --- a/src/backend/parser/cypher_gram.y +++ b/src/backend/parser/cypher_gram.y @@ -1500,6 +1500,14 @@ function_call: /* EXISTS((pattern)) - check for relationship/path existence */ $$ = (ast_node*)make_exists_pattern_expr($3, @1.first_line); } + | EXISTS '{' pattern_list '}' + { + /* Existential subquery brace form: EXISTS { (n)-->() } + * (ExistentialSubquery1 [1]/[3]). Reuses the pattern-existence + * transform; correlated outer variables resolve via the + * EXISTS_TYPE_PATTERN emitter's outer-alias lookup. */ + $$ = (ast_node*)make_exists_pattern_expr($3, @1.first_line); + } | EXISTS '(' IDENTIFIER '.' IDENTIFIER ')' { /* EXISTS(n.property) - unambiguous property existence check */