Commit bc891bf
Fix parse-tree malformation in OPTIONAL MATCH WHERE re-attach (#2378)
transform_cypher_optional_match_clause was calling transform_cypher_expr
with EXPR_KIND_JOIN_ON when re-attaching the detached WHERE as the
LEFT JOIN's ON condition. All other WHERE transforms in cypher_clause.c
use EXPR_KIND_WHERE, and there are three explicit
p_expr_kind == EXPR_KIND_WHERE guards (cypher_clause.c:5415, 5679, 6597)
that do load-bearing variable resolution for sub-pattern predicates --
walking up parent parsestates to rebind variables like `friend` inside
EXISTS { (friend)-[...]->(...) }.
Using EXPR_KIND_JOIN_ON bypassed those guards, so the sub-pattern fell
through to the "create new variable" path and produced a structurally
invalid parse tree. Under a release PG build the query happened to
produce correct-looking output, but under --enable-cassert the
downstream invariant checks aborted, crashing the backend and taking
down the regression run (reported by @MuhammadTahaNaveed).
Fix: use EXPR_KIND_WHERE, matching the pattern already established in
transform_cypher_clause_with_where at line 2619.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2d75e22 commit bc891bf
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2872 | 2872 | | |
2873 | 2873 | | |
2874 | 2874 | | |
2875 | | - | |
| 2875 | + | |
2876 | 2876 | | |
2877 | 2877 | | |
2878 | 2878 | | |
| |||
0 commit comments