hkjiang26 opened a new issue, #2507:
URL: https://github.com/apache/age/issues/2507

   **Bug description**
   
   Writing a Cypher `MATCH` pattern whose property-map value is a correlated 
`EXISTS { }` subquery — the subquery projects an aggregate through `WITH` and 
references the outer pattern variable — crashes the PostgreSQL backend with a 
segmentation fault. The backend process is terminated (`signal 11: Segmentation 
fault`) and the connection is dropped.
   
   **Access method**
   
   - Command line via `psql`, inside the official Docker container 
`apache/age:1.8.0`
   
   **Data setup**
   
   Only a single vertex is required — no labels, properties, or edges:
   
   ```pgsql
   CREATE EXTENSION IF NOT EXISTS age;
   LOAD 'age';
   SET search_path = ag_catalog, "$user", public;
   SELECT create_graph('graph_test');
   SELECT * FROM cypher('graph_test', $$ CREATE (n) $$) AS (c agtype);
   ```
   
   **Configuration**
   
   - None beyond the stock AGE extension. No additional modules (no PostGIS, 
etc.), default `search_path` handling as shown above.
   
   **Command that triggers the crash**
   
   ```pgsql
   SELECT * FROM cypher('graph_test', $$ MATCH (x {n0: EXISTS { WITH sum(0) AS 
n1, x RETURN 0 }}) RETURN 0 $$) AS (c agtype);
   ```
   
   ```
   server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
   connection to server was lost
   ```
   
   The server log shows the backend being killed:
   
   ```
   LOG:  client backend (PID NNN) was terminated by signal 11: Segmentation 
fault
   LOG:  terminating any other active server processes
   LOG:  all server processes terminated; reinitializing
   ```
   
   **Expected behavior**
   
   The query is valid Cypher: an `EXISTS` subquery that always returns one row 
is used as the value of a pattern property map. It should either match nodes 
and return normally, or raise a normal Cypher error — it must not crash the 
backend process. The same correlated subquery placed in a `WHERE` clause 
instead of a property map executes correctly (returns `0`), so the crash is 
specific to the property-map context.
   
   **Removing any one of the following makes the crash disappear:**
   
   - The subquery referencing the outer variable `x` (correlation)
   - An aggregate (e.g. `sum`) projected in the subquery's `WITH` clause
   - The `EXISTS` subquery being used as a pattern property-map value (same 
subquery in `WHERE` does not crash)
   
   **Environment**
   
   - Version: 1.8.0 (official `apache/age:1.8.0` Docker image)
   - PostgreSQL: 18.1 (Debian 18.1-1.pgdg13+2), x86_64
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to