apache / apache/age

Full-path `MERGE` fails with a path-shape error when two input rows match

Open
#2,529 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
4.8k
Forks
523
Avg merge
1d 2h
Merged PRs (30d)
9

Description

Docker image `apache/age:release_PG18_1.8.0`

**Reproduction**

```sql
LOAD 'age';
SET search_path = ag_catalog, public;
SELECT ag_catalog.create_graph('age_issue_case6');

SELECT *
FROM ag_catalog.cypher('age_issue_case6', $$
CREATE (:l1 {k10: '', k7: 'keep1', k9: 'r1', k8: 'k1', k0: 'v1'}),
(:l1 {k10: '', k7: 'keep2', k9: 'r2', k8: 'k2', k0: 'v2'})
$$) AS (v agtype);

SELECT *
FROM ag_catalog.cypher('age_issue_case6', $$
UNWIND [-308062748] AS alias0
MATCH (n0:l1)
WHERE n0.k10 ENDS WITH ''
REMOVE n0.k7
WITH alias0 AS alias1, n0.k9 AS alias2, n0.k8 AS alias3,
sin(toFloat(alias0)) AS alias4,
log10(abs(toFloat(id(n0))) + 1) AS alias5,
n0
WITH DISTINCT alias5 AS alias6, alias1, alias3 AS alias7,
n0.k0 AS alias8, trim(toString(n0.k10)) AS alias9, n0
MERGE p0 = (n0) <-[r0:rt10 {id: 31, k0: 'P1Xuov6KW'}]-
({id: 134, k0: 'WT03gW8'})
RETURN n0, r0, alias9, alias7, alias8,
r0.k8 AS alias10, n0.k9 AS alias11
$$) AS (n0 agtype, r0 agtype, alias9 agtype, alias7 agtype,
alias8 agtype, alias10 agtype, alias11 agtype);
```

**Expected**

The full pattern is matched or created independently for both matching input
vertices, and two result rows are returned.

**Actual**

```text
a path is of the form: [vertex, (edge, vertex)*i] where i >= 0
```

Contributor guide

Open the contributing guide

Research direction

Run the supplied SQL reproduction against apache/age:release_PG18_1.8.0 and trace the MERGE path-shape validation in the relevant AGE/PostgreSQL code. The fix is complete when the full pattern is matched or created independently for both matching input vertices and the query returns two result rows without the path-shape error.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.