YGY-001 opened a new issue, #2625:
URL: https://github.com/apache/age/issues/2625
## Environment
- Apache AGE `1.8.0`
- PostgreSQL `18.6`
- Docker image: `apache/age:release_PG18_1.8.0`
- Direct `psql` connection
## Setup
Run setup and each query as separate statements on a fresh graph:
```sql
LOAD 'age';
SET search_path = ag_catalog, public;
SELECT ag_catalog.create_graph('age_issue37');
SELECT *
FROM ag_catalog.cypher('age_issue37', $$
CREATE (a {id: 1})<-[:R]-(b {id: 2})
$$) AS (v agtype);
```
## Left — without the `EXISTS`
```sql
SELECT *
FROM ag_catalog.cypher('age_issue37', $$
OPTIONAL MATCH p0 = ({id: 1})<-[:R]-({id: 2})
RETURN p0
$$) AS (p agtype);
```
Observed: one row containing the matched path; `psql` exits 0.
## Right — with the correlated `EXISTS`
```sql
SELECT *
FROM ag_catalog.cypher('age_issue37', $$
OPTIONAL MATCH p0 = ({id: 1})<-[:R]-({id: 2})
WHERE EXISTS {
MATCH (x)
WITH DISTINCT p0
RETURN p0
}
RETURN p0
$$) AS (p agtype);
```
Expected: one row containing the same path as the LEFT query.
Actual:
```text
ERROR: could not find replacement targetlist entry for attno 2
```
`psql` exits 3 for this query.
The PostgreSQL backend remains available; a subsequent `SELECT 1` succeeds.
The LEFT and RIGHT statements use the same graph and outer path pattern. The
only difference is that RIGHT adds the correlated `WHERE EXISTS` subquery,
which projects `p0` through `WITH DISTINCT`.
--
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]